File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -327,12 +327,15 @@ def __eq__(self, other: object) -> bool:
327
327
return isinstance (other , AnyType )
328
328
329
329
def serialize (self ) -> JsonDict :
330
- return {'.class' : 'AnyType' }
330
+ return {'.class' : 'AnyType' , 'type_of_any' : self .type_of_any .name ,
331
+ 'source_any' : self .source_any .serialize () if self .source_any is not None else None }
331
332
332
333
@classmethod
333
334
def deserialize (cls , data : JsonDict ) -> 'AnyType' :
334
335
assert data ['.class' ] == 'AnyType'
335
- return AnyType (TypeOfAny .special_form )
336
+ source = data ['source_any' ]
337
+ return AnyType (TypeOfAny [data ['type_of_any' ]],
338
+ AnyType .deserialize (source ) if source is not None else None )
336
339
337
340
338
341
class UninhabitedType (Type ):
Original file line number Diff line number Diff line change @@ -3447,3 +3447,22 @@ import m # No error here
3447
3447
tmp/m/a.py:1: error: Unsupported operand types for + ("int" and "str")
3448
3448
[out2]
3449
3449
tmp/m/a.py:1: error: Unsupported operand types for + ("int" and "str")
3450
+
3451
+ [case testDisallowAnyExprIncremental]
3452
+ # cmd: mypy -m main
3453
+ # flags: --disallow-any-expr
3454
+
3455
+ [file ns.py]
3456
+ class Namespace:
3457
+ def __init__(self):
3458
+ self.user = 0
3459
+
3460
+ [file main.py]
3461
+ import ns
3462
+ user = ns.Namespace.user
3463
+
3464
+ [out1]
3465
+ tmp/main.py:2: error: Expression has type "Any"
3466
+
3467
+ [out2]
3468
+ tmp/main.py:2: error: Expression has type "Any"
You can’t perform that action at this time.
0 commit comments