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 for abstract-method #415

Closed
pylint-bot opened this issue Dec 16, 2014 · 1 comment
Closed

False positive for abstract-method #415

pylint-bot opened this issue Dec 16, 2014 · 1 comment
Labels

Comments

@pylint-bot
Copy link

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


Given the following code, Pylint emits an abstract-method. We could probably use the new .mro method for new style classes while searching for the abstract method (as it is done for abstract-class-instantiated). For old style classes, using the current approach should suffice.

#!python

import abc

class A(object):
    __metaclass__ = abc.ABCMeta
    @abc.abstractmethod
    def test(self): pass

class X(A):
    pass

class B(X):
    def x(self): pass

    test = x

B().test()



@pylint-bot
Copy link
Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Use a mro traversal for finding abstract methods. Closes issue #415.

This patch adds a new unimplemented_abstract_methods in pylint.checkers.utils,
which is used to obtain all the abstract methods which weren't implemented
anywhere in the mro of a class. The code works now by traversing the mro, gathering
all abstract methods encountered at each step and resolving the implemented ones
through either definition or assignment. This disables a couple of false
positives on classes with complex hierarchies.

msuozzo pushed a commit to msuozzo/pylint that referenced this issue Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant