Pylint: Erroneous inherit-non-class error when inheriting typing.Collection

Created on 25 Oct 2018  路  4Comments  路  Source: PyCQA/pylint

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 (9734baeb)

bug

Most helpful comment

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]

All 4 comments

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

Thanks for reporting a bug!

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

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]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

DevynCJohnson picture DevynCJohnson  路  3Comments

elirnm picture elirnm  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

DGalt picture DGalt  路  3Comments

adamtheturtle picture adamtheturtle  路  3Comments