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

Version 0.11.0 breaks with AttributeError #152

Closed
SethMMorton opened this issue Jun 16, 2020 · 9 comments · Fixed by #153
Closed

Version 0.11.0 breaks with AttributeError #152

SethMMorton opened this issue Jun 16, 2020 · 9 comments · Fixed by #153
Assignees
Labels

Comments

@SethMMorton
Copy link

SethMMorton commented Jun 16, 2020

When I run flake8 with the new pep8-naming version 0.11.0, I get an AttributeError from pep8ext_naming.py

$ .venv/bin/flake8
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/path/python/envs/3.7.6/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/path/python/envs/3.7.6/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/path/.venv/lib/python3.7/site-packages/flake8/checker.py", line 655, in _run_checks
    return checker.run_checks()
  File "/path/.venv/lib/python3.7/site-packages/flake8/checker.py", line 589, in run_checks
    self.run_ast_checks()
  File "/path/.venv/lib/python3.7/site-packages/flake8/checker.py", line 496, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/path/.venv/lib/python3.7/site-packages/pep8ext_naming.py", line 195, in visit_tree
    for error in self.visit_tree(child):
  File "/path/.venv/lib/python3.7/site-packages/pep8ext_naming.py", line 191, in visit_tree
    for error in self.visit_node(node):
  File "/path/.venv/lib/python3.7/site-packages/pep8ext_naming.py", line 201, in visit_node
    self.tag_class_functions(node)
  File "/path/.venv/lib/python3.7/site-packages/pep8ext_naming.py", line 242, in tag_class_functions
    iter_child_nodes(cls_node), ismetaclass, late_decoration)
  File "/path/.venv/lib/python3.7/site-packages/pep8ext_naming.py", line 259, in set_function_nodes_types
    name = d.func.id if isinstance(d, ast.Call) else d.id
AttributeError: 'Attribute' object has no attribute 'id'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ".venv/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "path/.venv/lib/python3.7/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/path/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 360, in run
    self._run(argv)
  File "/path/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 348, in _run
    self.run_checks()
  File "/path/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 262, in run_checks
    self.file_checker_manager.run()
  File "/path/.venv/lib/python3.7/site-packages/flake8/checker.py", line 323, in run
    self.run_parallel()
  File "/path/.venv/lib/python3.7/site-packages/flake8/checker.py", line 289, in run_parallel
    for ret in pool_map:
  File "/path/python/envs/3.7.6/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/path/python/envs/3.7.6/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
AttributeError: 'Attribute' object has no attribute 'id'

My guess is that it is not only Python 3.7, but that is all I've tried.

@SethMMorton SethMMorton changed the title Version 0.11.0 breaks on Python 3.7 Version 0.11.0 breaks with AttributeError on Python 3.7 Jun 16, 2020
@jparise
Copy link
Member

jparise commented Jun 16, 2020

On it.

@jparise jparise self-assigned this Jun 16, 2020
@jparise
Copy link
Member

jparise commented Jun 16, 2020

@SethMMorton any chance you can narrow down the snippet of code that's being analyzed and causing this to explode? I can see the issue, but I'd like to include something in the test suite to avoid future regressions.

@mirror25
Copy link

We are seeing this on Python 3.6 so the title should be corrected

@SethMMorton SethMMorton changed the title Version 0.11.0 breaks with AttributeError on Python 3.7 Version 0.11.0 breaks with AttributeError Jun 16, 2020
@sigmavirus24
Copy link
Member

Can you share a snippet of code that reproduces this regardless of Python version? That's far more important

@SethMMorton
Copy link
Author

SethMMorton commented Jun 16, 2020

I am working on a snippet, but I cannot just share my company's code so please be patient. I realize it wasn't only Python 3.7 - sorry I added that.

@jparise
Copy link
Member

jparise commented Jun 16, 2020

I've figured out what's going on here. It happens with the @module.decorator(arg) calling syntax. Fixing now.

@SethMMorton
Copy link
Author

SethMMorton commented Jun 16, 2020

Here is a minimal snippet. Remove the setter and it works.

class Foo:

    def __init__(self):
        self._bar = None

    @property
    def foo(self):
        return self._bar

    @foo.setter
    def foo(self, val):
        self._bar = val

@jparise
Copy link
Member

jparise commented Jun 16, 2020

Version 0.11.1 has just been released with a fix for this. Sorry about this, and thanks for your help and patience tracking it down!

@SethMMorton
Copy link
Author

Thank you for the quick turnaround. I have been in your shoes (except that the release happened before I went to bed, so the badness stagnated for 8 hours) and know how stress inducing it can be.

Many thanks.

@jparise jparise added the bug label Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants