@@ -5807,15 +5807,15 @@ def to_json_string(self, **kw: Any) -> str:
5807
5807
class ImportFrom :
5808
5808
"""Original type: directive = [ ... | ImportFrom of ... | ... ]"""
5809
5809
5810
- value : Tuple [Tok , ModuleName , List [Tuple [ Alias , Optional [ Alias ]] ]]
5810
+ value : Tuple [Tok , ModuleName , List [ImportFromKind ]]
5811
5811
5812
5812
@property
5813
5813
def kind (self ) -> str :
5814
5814
"""Name of the class representing this variant."""
5815
5815
return 'ImportFrom'
5816
5816
5817
5817
def to_json (self ) -> Any :
5818
- return ['ImportFrom' , (lambda x : [(lambda x : x .to_json ())(x [0 ]), (lambda x : x .to_json ())(x [1 ]), _atd_write_list ((lambda x : [( lambda x : x .to_json ())( x [ 0 ]), _atd_write_nullable (( lambda x : x . to_json ()))( x [ 1 ])] if isinstance ( x , tuple ) and len ( x ) == 2 else _atd_bad_python ( 'tuple of length 2' , x )))(x [2 ])] if isinstance (x , tuple ) and len (x ) == 3 else _atd_bad_python ('tuple of length 3' , x ))(self .value )]
5818
+ return ['ImportFrom' , (lambda x : [(lambda x : x .to_json ())(x [0 ]), (lambda x : x .to_json ())(x [1 ]), _atd_write_list ((lambda x : x .to_json ()))(x [2 ])] if isinstance (x , tuple ) and len (x ) == 3 else _atd_bad_python ('tuple of length 3' , x ))(self .value )]
5819
5819
5820
5820
def to_json_string (self , ** kw : Any ) -> str :
5821
5821
return json .dumps (self .to_json (), ** kw )
@@ -5945,7 +5945,7 @@ def from_json(cls, x: Any) -> 'Directive':
5945
5945
if isinstance (x , List ) and len (x ) == 2 :
5946
5946
cons = x [0 ]
5947
5947
if cons == 'ImportFrom' :
5948
- return cls (ImportFrom ((lambda x : (Tok .from_json (x [0 ]), ModuleName .from_json (x [1 ]), _atd_read_list (( lambda x : ( Alias .from_json ( x [ 0 ]), _atd_read_nullable ( Alias . from_json )( x [ 1 ])) if isinstance ( x , list ) and len ( x ) == 2 else _atd_bad_json ( 'array of length 2' , x )) )(x [2 ])) if isinstance (x , list ) and len (x ) == 3 else _atd_bad_json ('array of length 3' , x ))(x [1 ])))
5948
+ return cls (ImportFrom ((lambda x : (Tok .from_json (x [0 ]), ModuleName .from_json (x [1 ]), _atd_read_list (ImportFromKind .from_json )(x [2 ])) if isinstance (x , list ) and len (x ) == 3 else _atd_bad_json ('array of length 3' , x ))(x [1 ])))
5949
5949
if cons == 'ImportAs' :
5950
5950
return cls (ImportAs ((lambda x : (Tok .from_json (x [0 ]), ModuleName .from_json (x [1 ]), _atd_read_nullable (Alias .from_json )(x [2 ])) if isinstance (x , list ) and len (x ) == 3 else _atd_bad_json ('array of length 3' , x ))(x [1 ])))
5951
5951
if cons == 'ImportAll' :
@@ -7331,6 +7331,74 @@ def from_json_string(cls, x: str) -> 'IdInfo':
7331
7331
def to_json_string (self , ** kw : Any ) -> str :
7332
7332
return json .dumps (self .to_json (), ** kw )
7333
7333
7334
+ @dataclass
7335
+ class Direct :
7336
+ """Original type: import_from_kind = [ ... | Direct of ... | ... ]"""
7337
+
7338
+ value : Alias
7339
+
7340
+ @property
7341
+ def kind (self ) -> str :
7342
+ """Name of the class representing this variant."""
7343
+ return 'Direct'
7344
+
7345
+ def to_json (self ) -> Any :
7346
+ return ['Direct' , (lambda x : x .to_json ())(self .value )]
7347
+
7348
+ def to_json_string (self , ** kw : Any ) -> str :
7349
+ return json .dumps (self .to_json (), ** kw )
7350
+
7351
+
7352
+ @dataclass
7353
+ class Aliased :
7354
+ """Original type: import_from_kind = [ ... | Aliased of ... | ... ]"""
7355
+
7356
+ value : Tuple [Ident , Alias ]
7357
+
7358
+ @property
7359
+ def kind (self ) -> str :
7360
+ """Name of the class representing this variant."""
7361
+ return 'Aliased'
7362
+
7363
+ def to_json (self ) -> Any :
7364
+ return ['Aliased' , (lambda x : [(lambda x : x .to_json ())(x [0 ]), (lambda x : x .to_json ())(x [1 ])] if isinstance (x , tuple ) and len (x ) == 2 else _atd_bad_python ('tuple of length 2' , x ))(self .value )]
7365
+
7366
+ def to_json_string (self , ** kw : Any ) -> str :
7367
+ return json .dumps (self .to_json (), ** kw )
7368
+
7369
+
7370
+ @dataclass
7371
+ class ImportFromKind :
7372
+ """Original type: import_from_kind = [ ... ]"""
7373
+
7374
+ value : Union [Direct , Aliased ]
7375
+
7376
+ @property
7377
+ def kind (self ) -> str :
7378
+ """Name of the class representing this variant."""
7379
+ return self .value .kind
7380
+
7381
+ @classmethod
7382
+ def from_json (cls , x : Any ) -> 'ImportFromKind' :
7383
+ if isinstance (x , List ) and len (x ) == 2 :
7384
+ cons = x [0 ]
7385
+ if cons == 'Direct' :
7386
+ return cls (Direct (Alias .from_json (x [1 ])))
7387
+ if cons == 'Aliased' :
7388
+ return cls (Aliased ((lambda x : (Ident .from_json (x [0 ]), Alias .from_json (x [1 ])) if isinstance (x , list ) and len (x ) == 2 else _atd_bad_json ('array of length 2' , x ))(x [1 ])))
7389
+ _atd_bad_json ('ImportFromKind' , x )
7390
+ _atd_bad_json ('ImportFromKind' , x )
7391
+
7392
+ def to_json (self ) -> Any :
7393
+ return self .value .to_json ()
7394
+
7395
+ @classmethod
7396
+ def from_json_string (cls , x : str ) -> 'ImportFromKind' :
7397
+ return cls .from_json (json .loads (x ))
7398
+
7399
+ def to_json_string (self , ** kw : Any ) -> str :
7400
+ return json .dumps (self .to_json (), ** kw )
7401
+
7334
7402
@dataclass
7335
7403
class Item :
7336
7404
"""Original type: item"""
0 commit comments