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

AttributeError when __enter__ method returns tuple #26

Closed
gb14 opened this issue Apr 10, 2018 · 3 comments
Closed

AttributeError when __enter__ method returns tuple #26

gb14 opened this issue Apr 10, 2018 · 3 comments

Comments

@gb14
Copy link

gb14 commented Apr 10, 2018

After upgrading to 1.2.2 we are getting this error:

Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/ve/lib/python3.6/site-packages/flake8/checker.py", line 648, in _run_checks
    return checker.run_checks()
  File "/ve/lib/python3.6/site-packages/flake8/checker.py", line 579, in run_checks
    self.run_ast_checks()
  File "/ve/lib/python3.6/site-packages/flake8/checker.py", line 493, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/ve/lib/python3.6/site-packages/flake8_builtins.py", line 103, in run
    for line, offset, msg, rtype in value:
  File "/ve/lib/python3.6/site-packages/flake8_builtins.py", line 192, in check_with
    if var and var.id in BUILTINS:
AttributeError: 'Tuple' object has no attribute 'id'

This is caused by something like:

with my_manager() as (a, b):
  ....
@gb14 gb14 changed the title AttributeError when __enter__ method returns tuple AttributeError when __enter__ method returns tuple Apr 10, 2018
@gforcada
Copy link
Owner

@gb14 thanks for using and reporting your errors with flake8-builtins!

I didn't think of a context manager that returns more than one object that gets unpacked on the with statement right away, sure Python can be creative at a times 😄

I will try to fix that as soon as possible, or would you be interested to try to tackle this issue?

To begin with a test case would be great :-)

@gforcada
Copy link
Owner

@gb14 flake8-builtins 1.2.3 is out! Please give it a try

@gb14
Copy link
Author

gb14 commented Apr 11, 2018

Thank you :)

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

2 participants