question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bugbear 21.4.1 + 21.4.2 fails with AttributeError

See original GitHub issue

Newly updated bugbear 21.4.1 fails with AttributeError:

21:06:51 Traceback (most recent call last):
21:06:51   File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker
21:06:51     result = (True, func(*args, **kwds))
21:06:51   File "/usr/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
21:06:51     return list(map(*args))
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/flake8/checker.py", line 676, in _run_checks
21:06:51     return checker.run_checks()
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/flake8/checker.py", line 589, in run_checks
21:06:51     self.run_ast_checks()
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/flake8/checker.py", line 494, in run_ast_checks
21:06:51     for (line_number, offset, text, _) in runner:
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 36, in run
21:06:51     visitor.visit(self.tree)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 165, in visit
21:06:51     super().visit(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 253, in visit
21:06:51     return visitor(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 261, in generic_visit
21:06:51     self.visit(item)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 165, in visit
21:06:51     super().visit(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 253, in visit
21:06:51     return visitor(node)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 306, in visit_ClassDef
21:06:51     self.generic_visit(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 261, in generic_visit
21:06:51     self.visit(item)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 165, in visit
21:06:51     super().visit(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 253, in visit
21:06:51     return visitor(node)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 302, in visit_FunctionDef
21:06:51     self.generic_visit(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 261, in generic_visit
21:06:51     self.visit(item)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 165, in visit
21:06:51     super().visit(node)
21:06:51   File "/usr/lib/python3.6/ast.py", line 253, in visit
21:06:51     return visitor(node)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 321, in visit_With
21:06:51     self.check_for_b017(node)
21:06:51   File "/src/.tox/flake8-py36/lib/python3.6/site-packages/bugbear.py", line 442, in check_for_b017
21:06:51     hasattr(item_context.func, "attr")
21:06:51 AttributeError: 'Name' object has no attribute 'func'
21:06:51 """

See https://integration.wikimedia.org/ci/job/pywikibot-core-tox-docker/14952/console

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
cricalixcommented, Apr 1, 2021

Ok, test case added, and confirms that my in-flight fix fixes that case. I’ll have to walk the AST tree to get a better feel for what your syntax is doing, but it looks like there’s another layer of nesting in that case.

2reactions
DStapecommented, Apr 1, 2021

@cooperlees, @cricalix , here’s a stripped down example of code bugbear is error-ing out on for us:

import asyncio
from unittest import TestCase
 
 
class Foo:
    pass


class TestFoo(TestCase):
    def test_(self):
        with self.assertRaises(asyncio.CancelledError):
        #from asyncio import CancelledError  # no AttributeError
        #with self.assertRaises(CancelledError):
            Foo()

Note that when CancelledError is imported from asyncio, the AttributeError does not occur.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flake8-bugbear: A Plugin for Flake8 Finding Likely Bugs
Flake8-bugbear: A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and ...
Read more >
A plugin for Flake8 finding likely bugs and design problems in your ...
A cause of fear, anxiety, or irritation: *Overcrowding is often a bugbear for train commuters.* 2. ... bugbear 21.4.1 + 21.4.2 fails with...
Read more >
The flake8-bugbear from PyCQA - Coder Social
A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle. from...
Read more >
mypy plugin for loguru - PythonRepo
Raising an exception turns into an internal error for mypy which is ... Handler] AttributeError: module 'loguru' has no attribute 'Writable'.
Read more >
Ontology Components - DocShare.tips
21.4.1 Morgan's early influence . . . . . . . . . . . . . . . . . . ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found