File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -3616,7 +3616,7 @@ def accept(self,
36163616 not always_allow_any and
36173617 not self .chk .is_stub and
36183618 self .chk .in_checked_function () and
3619- has_any_type (typ )):
3619+ has_any_type (typ ) and not self . chk . current_node_deferred ):
36203620 self .msg .disallowed_any_type (typ , node )
36213621
36223622 if not self .chk .in_checked_function () or self .chk .current_node_deferred :
Original file line number Diff line number Diff line change @@ -6489,3 +6489,26 @@ reveal_type(Foo().y) # N: Revealed type is 'builtins.list[Any]'
64896489class Foo:
64906490 def bad(): # E: Method must have at least one argument
64916491 self.x = 0 # E: Name 'self' is not defined
6492+
6493+ [case testTypeAfterAttributeAccessWithDisallowAnyExpr]
6494+ # flags: --disallow-any-expr
6495+
6496+ def access_before_declaration(self) -> None:
6497+ obj = Foo('bar')
6498+ obj.value
6499+ x = 1
6500+
6501+ reveal_type(x) # N: Revealed type is 'builtins.int'
6502+ x = x + 1
6503+
6504+ class Foo:
6505+ def __init__(self, value: str) -> None:
6506+ self.value = value
6507+
6508+ def access_after_declaration(self) -> None:
6509+ obj = Foo('bar')
6510+ obj.value
6511+ x = 1
6512+
6513+ reveal_type(x) # N: Revealed type is 'builtins.int'
6514+ x = x + 1
You can’t perform that action at this time.
0 commit comments