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

Erroneous inherit-non-class error when inheriting typing.Collection #2570

Closed
lbenezriravin opened this issue Oct 25, 2018 · 5 comments
Closed

Comments

@lbenezriravin
Copy link
Contributor

lbenezriravin commented Oct 25, 2018

Steps to reproduce

run pylint on the following:

from typing import Collection

class NewCollection(Collection):
    pass

Current behavior

E0239: Inheriting 'Collection', which is not a class. (inherit-non-class)

Expected behavior

Don't raise an error. Collection is a class:

$ pipenv run python
Python 3.7.0 (default, Jun 28 2018, 08:12:18) 
[GCC 8.1.1 20180502 (Red Hat 8.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Collection
>>> type(Collection)
<class 'typing._GenericAlias'>
>>> 

pylint --version output

pylint 2.1.1
astroid 2.0.4
Python 3.7.0 (default, Jun 28 2018, 08:12:18) 
[GCC 8.1.1 20180502 (Red Hat 8.1.1-1)]

Edit: I have reproduced this on master (9734bae)

@lbenezriravin
Copy link
Contributor Author

This appears to happen with all (or most) of the generics in typing. Not specific to Collection

@PCManticore
Copy link
Contributor

Thanks for reporting a bug!

@user202729
Copy link

Not reproducible in the current version. The related issue 2568 with typing generic is still a problem, though.

@lbenezriravin
Copy link
Contributor Author

I can still reproduce it on master:

$ pipenv run pylint test.py 
************* Module testtest.py:3:0: E0239: Inheriting 'Collection', which is not a class. (inherit-non-class)

--------------------------------------------------------------------Your code has been rated at -6.67/10 (previous run: -6.67/10, +0.00)

$ cat test.py -p
from typing import Collection
class NewCollection(Collection):
    pass
$ pipenv graph
pylint==2.4.0.dev0
  - astroid [required: >=2.2.0,<3, installed: 2.2.5]
    - lazy-object-proxy [required: Any, installed: 1.4.1]
    - six [required: Any, installed: 1.12.0]
    - typed-ast [required: >=1.3.0, installed: 1.3.5]
    - wrapt [required: Any, installed: 1.11.1]
  - isort [required: >=4.2.5,<5, installed: 4.3.20]
  - mccabe [required: >=0.6,<0.7, installed: 0.6.1]

@cdce8p
Copy link
Member

cdce8p commented Oct 17, 2021

Related to #2377

This issue seems to be fixed when testing with the latest pylint version.
If you still encounter it, please report back and I'll reopen it.

@cdce8p cdce8p closed this as completed Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants