44
55from  __future__ import  annotations 
66
7- from  collections .abc  import  Iterable 
8- import  string 
97from  types  import  MappingProxyType 
10- from  typing  import  Any , BinaryIO , NamedTuple 
11- import  warnings 
128
139from  ._re  import  (
1410    RE_DATETIME ,
1814    match_to_localtime ,
1915    match_to_number ,
2016)
21- from  ._types  import  Key , ParseFloat , Pos 
17+ 
18+ TYPE_CHECKING  =  False 
19+ if  TYPE_CHECKING :
20+     from  collections .abc  import  Iterable 
21+     from  typing  import  IO , Any 
22+ 
23+     from  ._types  import  Key , ParseFloat , Pos 
2224
2325ASCII_CTRL  =  frozenset (chr (i ) for  i  in  range (32 )) |  frozenset (chr (127 ))
2426
3436
3537TOML_WS  =  frozenset (" \t " )
3638TOML_WS_AND_NEWLINE  =  TOML_WS  |  frozenset ("\n " )
37- BARE_KEY_CHARS  =  frozenset (string .ascii_letters  +  string .digits  +  "-_" )
39+ BARE_KEY_CHARS  =  frozenset (
40+     "abcdefghijklmnopqrstuvwxyz"  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  "0123456789"  "-_" 
41+ )
3842KEY_INITIAL_CHARS  =  BARE_KEY_CHARS  |  frozenset ("\" '" )
39- HEXDIGIT_CHARS  =  frozenset (string . hexdigits )
43+ HEXDIGIT_CHARS  =  frozenset ("abcdef"   "ABCDEF"   "0123456789" )
4044
4145BASIC_STR_ESCAPE_REPLACEMENTS  =  MappingProxyType (
4246    {
@@ -80,6 +84,8 @@ def __init__(
8084            or  not  isinstance (doc , str )
8185            or  not  isinstance (pos , int )
8286        ):
87+             import  warnings 
88+ 
8389            warnings .warn (
8490                "Free-form arguments for TOMLDecodeError are deprecated. " 
8591                "Please set 'msg' (str), 'doc' (str) and 'pos' (int) arguments only." ,
@@ -115,7 +121,7 @@ def __init__(
115121        self .colno  =  colno 
116122
117123
118- def  load (fp : BinaryIO , / , * , parse_float : ParseFloat  =  float ) ->  dict [str , Any ]:
124+ def  load (fp : IO [ bytes ] , / , * , parse_float : ParseFloat  =  float ) ->  dict [str , Any ]:
119125    """Parse TOML from a binary file object.""" 
120126    b  =  fp .read ()
121127    try :
@@ -139,7 +145,7 @@ def loads(s: str, /, *, parse_float: ParseFloat = float) -> dict[str, Any]:  # n
139145            f"Expected str object, not '{ type (s ).__qualname__ }  '" 
140146        ) from  None 
141147    pos  =  0 
142-     out  =  Output (NestedDict (),  Flags () )
148+     out  =  Output ()
143149    header : Key  =  ()
144150    parse_float  =  make_safe_parse_float (parse_float )
145151
@@ -290,9 +296,10 @@ def append_nest_to_list(self, key: Key) -> None:
290296            cont [last_key ] =  [{}]
291297
292298
293- class  Output (NamedTuple ):
294-     data : NestedDict 
295-     flags : Flags 
299+ class  Output :
300+     def  __init__ (self ) ->  None :
301+         self .data  =  NestedDict ()
302+         self .flags  =  Flags ()
296303
297304
298305def  skip_chars (src : str , pos : Pos , chars : Iterable [str ]) ->  Pos :
0 commit comments