Skip to content

Commit b23f46c

Browse files
committed
Update test case
1 parent ca714ae commit b23f46c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

mypy/checkmember.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,8 @@ def analyze_var(
886886
if isinstance(typ, FunctionLike) and not typ.is_type_obj():
887887
call_type = typ
888888
elif var.is_property:
889-
call_type = get_proper_type(
890-
_analyze_member_access("__call__", typ, mx.copy_modified(self_type=typ))
891-
)
889+
deco_mx = mx.copy_modified(original_type=typ, self_type=typ, is_lvalue=False)
890+
call_type = get_proper_type(_analyze_member_access("__call__", typ, deco_mx))
892891
else:
893892
call_type = typ
894893

test-data/unit/check-functions.test

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,6 +2819,8 @@ class Child(Base):
28192819
@decorator
28202820
def foo(self) -> int:
28212821
return 42
2822+
reveal_type(Child().foo) # N: Revealed type is "builtins.int"
2823+
Child().foo = 1 # E: Property "foo" defined in "Child" is read-only
28222824

28232825
reveal_type(Child().foo) # N: Revealed type is "builtins.int"
28242826

@@ -2835,14 +2837,13 @@ class not_a_decorator:
28352837
def __init__(self, fn): ...
28362838

28372839
class BadChild2(Base):
2840+
# Override error not shown as accessing 'foo' on BadChild2 returns Any.
28382841
@property
28392842
@not_a_decorator
2840-
def foo(self) -> int: # E: Signature of "foo" incompatible with supertype "Base" \
2841-
# N: Superclass: \
2842-
# N: int \
2843-
# N: Subclass: \
2844-
# N: not_a_decorator
2843+
def foo(self) -> int:
28452844
return 42
2845+
reveal_type(BadChild2().foo) # E: "not_a_decorator" not callable \
2846+
# N: Revealed type is "Any"
28462847
[builtins fixtures/property.pyi]
28472848

28482849
[case explicitOverride]

0 commit comments

Comments
 (0)