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

Python 3.7 pylint 2.0.0.dev2 AttributeError: module 'astroid.nodes' has no attribute 'CallFunc' #173

Closed
fsnidely opened this issue Jul 5, 2018 · 26 comments

Comments

@fsnidely
Copy link

fsnidely commented Jul 5, 2018

I'm trying to use pylint for Python 3.7, which isn't supported until pylint 2.0.0, so it is still in dev. However, I thought I would bring this here as pylint 2.0.0 fails when loading pylint_django, simply when checking the version (no file to be linted).

2062$ pylint --version
pylint 2.0.0.dev2
astroid 2.0.0.dev4
Python 3.7.0 (default, Jun 28 2018, 02:32:19) 
[GCC 5.4.0 20160609]

Fails when loading the plugin pylint_django:

2061$ pylint --version --load-plugins pylint_django
Traceback (most recent call last):
  File "/home/ferd/.virtualenvs/python37/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint/__init__.py", line 18, in run_pylint
    Run(sys.argv[1:])
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint/lint.py", line 1293, in __init__
    linter.load_plugin_modules(self._plugins)
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint/lint.py", line 502, in load_plugin_modules
    module = modutils.load_module_from_name(modname)
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/astroid/modutils.py", line 187, in load_module_from_name
    return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/astroid/modutils.py", line 230, in load_module_from_modpath
    module = imp.load_module(curname, mp_file, mp_filename, mp_desc)
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/imp.py", line 245, in load_module
    return load_package(name, filename)
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/imp.py", line 217, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint_django/__init__.py", line 7, in <module>
    from pylint_django import plugin
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint_django/plugin.py", line 9, in <module>
    from pylint_django import transforms  # noqa, pylint: disable=unused-import
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint_django/transforms/__init__.py", line 12, in <module>
    foreignkey.add_transform(MANAGER)
  File "/home/ferd/.virtualenvs/python37/lib/python3.7/site-packages/pylint_django/transforms/foreignkey.py", line 59, in add_transform
    manager.register_transform(nodes.CallFunc, inference_tip(infer_key_classes),
AttributeError: module 'astroid.nodes' has no attribute 'CallFunc'

Freeze:

astroid==2.0.0.dev4
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
Pillow==5.2.0
pylint==2.0.0.dev2
pylint-django==0.11.1
pylint-plugin-utils==0.3
six==1.11.0
wrapt==1.10.11
@atodorov
Copy link
Contributor

atodorov commented Jul 6, 2018

@carlio I think astroid has changed some of the node names. I've seen some of the different node names at a pylint workshop I held recently.

How do we want to handle this? Try to be backwards and forwards compatible or just require newer astroid/pylint as dependencies ?

@rdrey
Copy link

rdrey commented Jul 6, 2018

I'm struggling to install pylint_django in py3.7 with pipenv because the constraint astroid<2.0 is not playing well with pylint>=2.0.0.dev2. Could you maybe release your own dev / --pre version of pylint-django?

@federicobond
Copy link
Contributor

federicobond commented Jul 10, 2018

astroid 2.0 is Python 3 only, so I think we should be compatible with previous versions until support for Django 1.11 is dropped.

If we can get a Pylint 2.x build running in CI (with failures ignored for now), I can tackle some of these issues, but I don’t know enough tox to do it.

Update: pylint-plugin-utils has dropped support for Python 2, so we don't have much of a choice here.

@ramaprv
Copy link

ramaprv commented Jul 12, 2018

Any updates on this ?

@atodorov
Copy link
Contributor

I've been trying to get Travis to execute tests with Python 3.7 and the latest pylint/astroid but without luck. @federicobond my code is in py37-pylint-dev branch if you want to take a look.

@carlio
Copy link
Collaborator

carlio commented Jul 12, 2018

@atodorov I think that keeping compat/backwards support layers is probably not worth it any more unless it's easy. There are lots of changes to django, astroid, pylint and python so it really becomes hard to keep everything going. Certainly when I tried that with this and other libs it made the code worse ans therefore the library I was writing worse, and added lots of additional vectors for bugs...

Simple things is fine, see this for example https://github.com/PyCQA/pylint-plugin-utils/blob/master/pylint_plugin_utils/__init__.py#L2 so I think a mild 'compat.py' isn't a huge problem for just renaming nodes etc, but I wouldn't put too much emphasis on keeping old versions of libs working with new versions of pylint-django.

If you're using old pylint/old django then use old pylint-django!

@carlio
Copy link
Collaborator

carlio commented Jul 15, 2018

pylint 2.0 and android 2.0 just got released which might affect this.

@atodorov
Copy link
Contributor

@carlio I'm still not quite sure how to reproduce locally.

Everything was working fine for me with pylint/astroid 2.0 but an older pylint-plugin-utils.

With pylint-plugin-utils 0.3 and pylint/astroid 2.0 I see the traceback from comment #0. I also see you've merged a PR that seems related. Maybe we need a new version of pylint-plugin-utils and to bump the minimum required version in setup.py ?

@carlio
Copy link
Collaborator

carlio commented Jul 16, 2018

@atodorov I can bump the pylint-plugin-utils release, also I can add you to that team/group if you like (as far as I know only pylint-django uses it a lot, pylint-celery isn't used much).

@carlio
Copy link
Collaborator

carlio commented Jul 16, 2018

@atodorov pylint-plugin-utils 0.4 just released. I didn't pin the pylint version in that lib, that's something that should be chosen in the pylint-django (or other plugin) libs I feel.

atodorov added a commit that referenced this issue Jul 16, 2018
also drop testing with Python 2.7 b/c pylint 2.0 is compatible
only with Python 3
@ochronus
Copy link

ochronus commented Jul 18, 2018

Still getting the same error with pipenv, python 3.7.0. Pip freeze output:

astroid==2.0  
pylint==2.0.0  
pylint-django==0.11.1  
pylint-plugin-utils==0.4

@w-flo
Copy link

w-flo commented Jul 18, 2018

@ochronus AIUI, it's fixed in master, but not released yet. So we need some patience. ;-)

@atodorov
Copy link
Contributor

or a pull request to fix the remaining test failures :)

@ochronus
Copy link

Oh, my bad, since it was closed I thought it's out in the wild :) thx for the heads up!

@allthatilk
Copy link

Can I ask what the status is currently on this? I've just started getting this issue myself.

@gothraven
Copy link

Can't wait for this to be fixed, Thanks a lot 👍

@federicobond
Copy link
Contributor

Do not wait, do :)

@gothraven
Copy link

I'm not that advanced, but sure, i'll try that out

jambonrose added a commit to jambonsw/django-improved-user that referenced this issue Jul 19, 2018
jambonrose pushed a commit to jambonsw/django-improved-user that referenced this issue Jul 19, 2018
✅🔨 Fix linting errors in tests

Upgrade:

* faker from 0.8.15 to 0.8.17
* sphinx-rtd-theme from 0.3.1 to 0.4.0
* sphinx from 1.7.4 to 1.7.6
* django-extensions from 2.0.7 to 2.1.0
* astroid from 1.6.4 to 1.6.5
* pylint from 1.9.1 to 1.9.2
* setuptools from 39.2.0 to 40.0.0
* tox from 3.0.0 to 3.1.2

Further upgrades to PyLint, Astroid, and pylint-django ignored:

- pylint-dev/pylint-django#173
- pylint-dev/pylint-django#165
@demeralde
Copy link

Just read through this thread but I'm still lost. What do I need to do to fix this error?

@ghost
Copy link

ghost commented Jul 22, 2018

Workaround before new version is released:

pip uninstall pylint-django
pip --no-cache-dir install git+https://github.com/PyCQA/pylint-django.git@4316c3d90f4ac6cbbeddfc8d431f5d4e031d5cf1

@carlio
Copy link
Collaborator

carlio commented Jul 22, 2018

@atodorov this fixed this problem in another lib I had - landscapeio/requirements-detector@5c97a18

Not sure if that's how you'd like to fix it here but seems simple enough so might be worth thinking about.

@carlio
Copy link
Collaborator

carlio commented Jul 22, 2018

@dspacejs temporarily, pylint<2 and astroid<2 would probably fix your local build. v2 of both broke a few things in prospector and several dependent libraries so using old versions is probably the quickest fix while we catch up.

DA-admin pushed a commit to datadvance/DjangoChannelsGraphqlWs that referenced this issue Jul 22, 2018
- Parallel execution initially introduced.
- Tests added. Tests are split into different files.

Cosmetics:
- Plugin `pylint-django` disabled until new release is here (current
  version is 0.11.1) because of the bug:
  pylint-dev/pylint-django#173.
- Dependencies updated.
- README.md updated.
@atodorov
Copy link
Contributor

@carlio we've already taken care of the node name changes introduced by astroid 2.0. Currently a few test cases are failing. From what I can tell the inference works differently and whenever we try to compare against expected class names (e.g. subclasses of Factory) that fails. Why and how I still can't figure out.

@demeralde
Copy link

Installing an older version of pylint worked for me as a workaround:

pipenv install -d pylint==1.9.3

@w-flo
Copy link

w-flo commented Jul 25, 2018

The latest released version of pylint-django (2.0, it's only a few hours old) works for me on python 3.7.

@demeralde
Copy link

Oh thanks, just tried it and it does for me too. Didn't realise it was released

rexcare added a commit to rexcare/vertex that referenced this issue May 30, 2023
✅🔨 Fix linting errors in tests

Upgrade:

* faker from 0.8.15 to 0.8.17
* sphinx-rtd-theme from 0.3.1 to 0.4.0
* sphinx from 1.7.4 to 1.7.6
* django-extensions from 2.0.7 to 2.1.0
* astroid from 1.6.4 to 1.6.5
* pylint from 1.9.1 to 1.9.2
* setuptools from 39.2.0 to 40.0.0
* tox from 3.0.0 to 3.1.2

Further upgrades to PyLint, Astroid, and pylint-django ignored:

- pylint-dev/pylint-django#173
- pylint-dev/pylint-django#165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests