JBKahn / flake8-print

flake8
MIT License
119 stars 22 forks source link

AttributeError: 'Name' object has no attribute 'arg' #25

Closed abachm closed 6 years ago

abachm commented 6 years ago

When upgrading to latest version of flake8-print (3.0.0) and using flake8 (3.5.0) I get the above error

[anders:~/tmp] [e] 7s $ flake8 -j 1 e/
Traceback (most recent call last):
  File "/home/anders/tmp/e/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/main/application.py", line 396, in run
    self._run(argv)
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/main/application.py", line 384, in _run
    self.run_checks()
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/main/application.py", line 310, in run_checks
    self.file_checker_manager.run()
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/checker.py", line 321, in run
    self.run_serial()
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/checker.py", line 305, in run_serial
    checker.run_checks()
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/checker.py", line 579, in run_checks
    self.run_ast_checks()
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8/checker.py", line 493, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8_print.py", line 88, in run
    parser.visit(self.tree)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/usr/lib/python2.7/ast.py", line 249, in generic_visit
    self.visit(item)
  File "/usr/lib/python2.7/ast.py", line 241, in visit
    return visitor(node)
  File "/home/anders/tmp/e/local/lib/python2.7/site-packages/flake8_print.py", line 49, in visit_FunctionDef
    if arg.arg in PRINT_FUNCTION_NAMES:
AttributeError: 'Name' object has no attribute 'arg'
JBKahn commented 6 years ago

I'll release a fix when I get to work. Must have missed something in my unit and integration tests. I'll use a getattr. Thanks for reporting it!

JBKahn commented 6 years ago

Hmm I'm on 27 on my machine and cannot reproduce it. Can you provide the version of python2.7 you're using?

JBKahn commented 6 years ago

Or a code snippet it's crashing on

abachm commented 6 years ago

$ python --version Python 2.7.14

I have a virtual env with only flake8 + flake8-print installed and then running flake8 on that virtual env crashes it

JBKahn commented 6 years ago

identified, seems to work locally. Will release a hotfix.

JBKahn commented 6 years ago

shipped