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

Passing extras key as a variable causes crash #61

Open
jonyscathe opened this issue Oct 7, 2022 · 1 comment
Open

Passing extras key as a variable causes crash #61

jonyscathe opened this issue Oct 7, 2022 · 1 comment

Comments

@jonyscathe
Copy link

I know this is a bit of a weird edge case that isn't likely to come up too often, but things seem to go a bit wrong if an extras key is a variable.

I am using this in a test case for a custom logger class with code:
test_logger.info('My test message', extra={id_type: id_value})

But flake8 crashes out with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 621, in _run_checks
    return checker.run_checks()
  File "/usr/local/lib/python3.10/site-packages/flake8_noqa/noqa_filter.py", line 189, in run_checks
    result = super().run_checks(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 531, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 435, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/usr/local/lib/python3.10/site-packages/logging_format/api.py", line 35, in run
    visitor.visit(self.tree)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/ast.py", line 418, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/ast.py", line 420, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/logging_format/visitor.py", line 114, in visit_Call
    super(LoggingVisitor, self).visit(child)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/logging_format/visitor.py", line 187, in visit_keyword
    super(LoggingVisitor, self).generic_visit(node)
  File "/usr/local/lib/python3.10/ast.py", line 420, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.10/ast.py", line 410, in visit
    return visitor(node)
  File "/usr/local/lib/python3.10/site-packages/logging_format/visitor.py", line 150, in visit_Dict
    if key is not None and key.s in RESERVED_ATTRS:
AttributeError: 'Name' object has no attribute 's'
"""

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

Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/usr/local/lib/python3.10/site-packages/flake8/main/application.py", line 336, in run
    self._run(argv)
  File "/usr/local/lib/python3.10/site-packages/flake8/main/application.py", line 325, in _run
    self.run_checks()
  File "/usr/local/lib/python3.10/site-packages/flake8/main/application.py", line 229, in run_checks
    self.file_checker_manager.run()
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 250, in run
    self.run_parallel()
  File "/usr/local/lib/python3.10/site-packages/flake8/checker.py", line 217, in run_parallel
    for ret in pool_map:
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
AttributeError: 'Name' object has no attribute 's'
@matiasrasmussen
Copy link

matiasrasmussen commented Nov 29, 2022

I'm facing the same issue.

Check out my PR ☝️ maybe this is enough to solve the problem?

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

Successfully merging a pull request may close this issue.

2 participants