11import codecs
2- import re
32from typing import Any , Optional , Tuple
43
5- from .core import IDNAError , alabel , decode , encode , ulabel
6-
7- _unicode_dots_re = re .compile ("[\u002e \u3002 \uff0e \uff61 ]" )
4+ from .core import IDNAError , _unicode_dots_re , alabel , decode , encode , ulabel
85
96
107class Codec (codecs .Codec ):
@@ -20,7 +17,7 @@ class Codec(codecs.Codec):
2017
2118 def encode (self , data : str , errors : str = "strict" ) -> Tuple [bytes , int ]: # ty: ignore[invalid-method-override]
2219 if errors != "strict" :
23- raise IDNAError ('Unsupported error handling "{}"' . format ( errors ) )
20+ raise IDNAError (f 'Unsupported error handling "{ errors } "' )
2421
2522 if not data :
2623 return b"" , 0
@@ -29,7 +26,7 @@ def encode(self, data: str, errors: str = "strict") -> Tuple[bytes, int]: # ty:
2926
3027 def decode (self , data : bytes , errors : str = "strict" ) -> Tuple [str , int ]: # ty: ignore[invalid-method-override]
3128 if errors != "strict" :
32- raise IDNAError ('Unsupported error handling "{}"' . format ( errors ) )
29+ raise IDNAError (f 'Unsupported error handling "{ errors } "' )
3330
3431 if not data :
3532 return "" , 0
@@ -51,7 +48,7 @@ class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
5148
5249 def _buffer_encode (self , data : str , errors : str , final : bool ) -> Tuple [bytes , int ]: # ty: ignore[invalid-method-override]
5350 if errors != "strict" :
54- raise IDNAError ('Unsupported error handling "{}"' . format ( errors ) )
51+ raise IDNAError (f 'Unsupported error handling "{ errors } "' )
5552
5653 if not data :
5754 return b"" , 0
@@ -94,7 +91,7 @@ class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
9491
9592 def _buffer_decode (self , data : Any , errors : str , final : bool ) -> Tuple [str , int ]: # ty: ignore[invalid-method-override]
9693 if errors != "strict" :
97- raise IDNAError ('Unsupported error handling "{}"' . format ( errors ) )
94+ raise IDNAError (f 'Unsupported error handling "{ errors } "' )
9895
9996 if not data :
10097 return ("" , 0 )
0 commit comments