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

invalid-length-return-type (PLE0303) - false positive when __len__ raises an exception #11023

Closed
DetachHead opened this issue Apr 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@DetachHead
Copy link

class Foo:
    def __len__(): # error: `__len__` does not return a non-negative integer
        raise Exception

playground

use case

i have a subclass of a type from a 3rd party module that uses __len__ in a very misleading way, so i want to ban people from using it on my subclass:

from typing import override, Never

class Bar(Foo):
    @override
    def __len__() -> Never:
        raise Exception("__len__ is banned on this class")
@charliermarsh
Copy link
Member

I believe this is fixed on main.

@charliermarsh
Copy link
Member

Via #11017. Sorry about that.

@charliermarsh charliermarsh added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants