Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubtest: Abstract properties are not detected #13646

Closed
sobolevn opened this issue Sep 11, 2022 · 4 comments · Fixed by #13647
Closed

stubtest: Abstract properties are not detected #13646

sobolevn opened this issue Sep 11, 2022 · 4 comments · Fixed by #13647
Labels
bug mypy got something wrong topic-stubtest

Comments

@sobolevn
Copy link
Member

Code:

from abc import abstractmethod

class Some:
    @property
    @abstractmethod
    def x(self) -> int:
         return 1

Stub:

class Some:
    @property
    def x(self) -> int: ...

No errors are shown.
It should raise an error about abstract state mismatch.
Realted python/typeshed#8726

@AlexWaygood
Copy link
Member

I thought you already fixed this in #13323 (comment)? It just hasn't been released yet?

@sobolevn
Copy link
Member Author

Sorry, I did not mention: I am using master version (0f17aff06ac1c05c442ba989e23655a2c6adbfbf) of course. We even have a test for it here:

mypy/mypy/test/teststubtest.py

Lines 1391 to 1403 in 0f17aff

yield Case(
stub="""
class AP1:
def some(self) -> int: ...
""",
runtime="""
class AP1:
@property
@abstractmethod
def some(self) -> int: ...
""",
error="AP1.some",
)

But, for some reason the example above is not reported.

@sobolevn
Copy link
Member Author

Oh, this is why:

             class AP1: 
                 def some(self) -> int: ... 

We miss @property decorator there.

@AlexWaygood
Copy link
Member

Got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-stubtest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants