Comments (4)
Could you also share the snippet of code that's producing this issue? It appears to be around line 363 of the active file.
Assuming Python 2, I'm not familiar with the case where an ast.ExceptHandler
's name
attribute isn't an ast.Name
node. Perhaps an old-style except:
syntax?
from pep8-naming.
Thanks for the pointer! I tracked it down to the following code snippet. And yes this is with python 2.7.15
#!/usr/bin/python
import socket
try:
data = socket.gethostbyaddr('127.0.0.1')
hostname = data[0]
ip_address = data[2][0]
except (socket.herror, socket.gaierror) as (errno, error_string):
print errno, error_string
And this reproduces the issue:
[root@3cc3a5f9a39b /tmp]# flake8 -j 1 foo.py
Traceback (most recent call last):
File "/opt/stackstorm/virtualenvs/stackstorm/bin/flake8", line 11, in <module>
sys.exit(main())
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/main/application.py", line 396, in run
self._run(argv)
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/main/application.py", line 384, in _run
self.run_checks()
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/main/application.py", line 310, in run_checks
self.file_checker_manager.run()
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/checker.py", line 321, in run
self.run_serial()
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/checker.py", line 305, in run_serial
checker.run_checks()
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/checker.py", line 579, in run_checks
self.run_ast_checks()
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/flake8/checker.py", line 493, in run_ast_checks
for (line_number, offset, text, check) in runner:
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 158, in visit_tree
for error in self.visit_tree(child):
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 158, in visit_tree
for error in self.visit_tree(child):
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 154, in visit_tree
for error in self.visit_node(node):
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 175, in visit_node
for error in visitor_method(node, parents, ignore_names):
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 413, in visit_excepthandler
for error in self._find_errors(node, parents):
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 377, in _find_errors
for name in _extract_names(assignment_target):
File "/opt/stackstorm/virtualenvs/stackstorm/lib/python2.7/site-packages/pep8ext_naming.py", line 462, in _extract_names
yield assignment_target.name.id
AttributeError: 'Tuple' object has no attribute 'id'```
from pep8-naming.
This code does actually work by the way, here's an invalid ip address
#!/usr/bin/python
import socket
try:
data = socket.gethostbyaddr('127.0111.0.1')
hostname = data[0]
ip_address = data[2][0]
except (socket.herror, socket.gaierror) as (errno, error_string):
print errno, error_string
[root@3cc3a5f9a39b tmp]# python foo.py
1 Unknown host
from pep8-naming.
Looks like both of these exceptions return a value as a Tuple:
"The accompanying value is a pair (error, string) representing an error returned by a library call"
https://docs.python.org/2/library/socket.html#socket.herror
https://docs.python.org/2/library/socket.html#socket.gaierror
from pep8-naming.
Related Issues (20)
- TypedDict classes should be exempt from N815 HOT 10
- Renaming default branch to main HOT 1
- Drop dependency on flake8-polyfill HOT 2
- N815 is not being reported HOT 4
- N815 is not being reported HOT 1
- N816 does not make sense HOT 1
- False positive for N805 in a child class HOT 3
- False positive for HTTP request handler do_METHOD methods HOT 1
- False Error N805 HOT 1
- "camelcase imported as lowercase" failure in an import of a package or module HOT 12
- Add flake8_polyfill as requirement HOT 2
- Deprecation warning for options HOT 1
- Detect @classproperty mtehods as class methods HOT 3
- Feature request: ignore `N802` for methods marked with `@override` HOT 1
- Add naming rule for instance variables HOT 2
- ignore-names globbing is not case-sensitive on Windows HOT 1
- Add option to ignore N812 for specific packages
- New release? HOT 1
- `N803`, `N804` and `N805` should also ignore methods marked with `@override` HOT 1
- Package available but broken for python 3.7 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pep8-naming.