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

False positive (incompatible_override) with properties #650

Closed
mflova opened this issue Jun 24, 2023 · 2 comments · Fixed by #653
Closed

False positive (incompatible_override) with properties #650

mflova opened this issue Jun 24, 2023 · 2 comments · Fixed by #653

Comments

@mflova
Copy link
Contributor

mflova commented Jun 24, 2023

I am surprised how this feature could detect many cases that mypy could not after running it into one of my repos. However, it seems that @property makes this tool raise incompatible_override when overriding a property. I will try later if it also fails with @typing.override

Minimal example that triggers this issue:

class A:

    @property
    def prop(self):
        return ()

class B(A):

    @property
    def prop(self):
        return ("New tuple",)

Output:

Value of prop incompatible with base class <class 'delete.A'> (code: incompatible_override)
  Base class: 'Literal[<property object at 0x000002682790C6D0>]'
  Child class: 'Literal[<property object at 0x00000268294BFB50>]'
  Cannot assign Literal[<property object at 0x00000268294BFB50>] to Literal[<property object at 0x000002682790C6D0>]  
@JelleZijlstra
Copy link
Contributor

Thanks for reporting. I haven't tested incompatible_override very well yet (that's why it's off by default), but this definitely needs to be fixed.

@mflova
Copy link
Contributor Author

mflova commented Jul 4, 2023

Great! Thank you so much! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants