Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve error message for type-abstract errors #18711

Open
dannyjeck opened this issue Feb 19, 2025 · 0 comments
Open

Improve error message for type-abstract errors #18711

dannyjeck opened this issue Feb 19, 2025 · 0 comments
Labels

Comments

@dannyjeck
Copy link

dannyjeck commented Feb 19, 2025

Feature
Add more details to the [type-abstract] error message.

Pitch

If I have the following abstract base class

class BaseClass(abc.ABC):

    @abstractmethod
    def method1(self): ...

    @abstractmethod
    def method2(self): ...

    @abstractmethod
    def method3(self): ...

And later I make a subclass of that base class

class ExampleSubClass(BaseClass):

    def method1(self): ...

    def method2(self): ...

    #but I forgot to override method3

Then I will get the following error when I try to use ExampleSubClass in application code: Only concrete class can be given where "type[ExampleSubClass]" is expected [type-abstract]

It would be great if the error message specified why ExampleSubClass is not a concrete class. An ideal error message would look something like: "Only concrete class can be given where type[ExampleSubClass] is expected. ExampleSubClass has abstract methods [method3]"

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

No branches or pull requests

1 participant