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

Undefined names: Add missing imports #1219

Merged
merged 2 commits into from
Sep 10, 2019
Merged

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Jun 17, 2019

flake8 testing of https://github.com/dependabot/dependabot-core on Python 3.7.1

$ flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics

./python/spec/fixtures/setup_files/with_open.py:10:9: F821 undefined name 'io'
file3 = io.open("some_file", "r")
        ^
./python/spec/fixtures/setup_files/with_open.py:16:17: F821 undefined name 'os'
    return open(os.path.join(os.path.dirname(__file__), fname)).read()
                ^
./python/spec/fixtures/setup_files/with_open.py:16:30: F821 undefined name 'os'
    return open(os.path.join(os.path.dirname(__file__), fname)).read()
                             ^
./python/spec/fixtures/setup_files/with_parse_reqs.py:3:29: F821 undefined name 'parse_requirements'
reqs = [str(r.req) for r in parse_requirements('requirements.txt', session=PipSession()) if r.req is not None]
                            ^
./python/spec/fixtures/setup_files/with_parse_reqs.py:3:76: F821 undefined name 'PipSession'
reqs = [str(r.req) for r in parse_requirements('requirements.txt', session=PipSession()) if r.req is not None]
                                                                           ^
./python/spec/fixtures/setup_files/with_pbr.py:4:14: F821 undefined name 'setuptools'
    packages=setuptools.find_packages(),
             ^
6     F821 undefined name 'io'
6

E901,E999,F821,F822,F823 are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety.

  • F821: undefined name name
  • F822: undefined name name in __all__
  • F823: local variable name referenced before assignment
  • E901: SyntaxError or IndentationError
  • E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree

cclauss added 2 commits June 17, 2019 17:10
[flake8](http://flake8.pycqa.org) testing of https://github.com/dependabot/dependabot-core on Python 3.7.1

$ __flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics__
```
./python/spec/fixtures/setup_files/with_open.py:10:9: F821 undefined name 'io'
file3 = io.open("some_file", "r")
        ^
./python/spec/fixtures/setup_files/with_open.py:16:17: F821 undefined name 'os'
    return open(os.path.join(os.path.dirname(__file__), fname)).read()
                ^
./python/spec/fixtures/setup_files/with_open.py:16:30: F821 undefined name 'os'
    return open(os.path.join(os.path.dirname(__file__), fname)).read()
                             ^
./python/spec/fixtures/setup_files/with_parse_reqs.py:3:29: F821 undefined name 'parse_requirements'
reqs = [str(r.req) for r in parse_requirements('requirements.txt', session=PipSession()) if r.req is not None]
                            ^
./python/spec/fixtures/setup_files/with_parse_reqs.py:3:76: F821 undefined name 'PipSession'
reqs = [str(r.req) for r in parse_requirements('requirements.txt', session=PipSession()) if r.req is not None]
                                                                           ^
./python/spec/fixtures/setup_files/with_pbr.py:4:14: F821 undefined name 'setuptools'
    packages=setuptools.find_packages(),
             ^
6     F821 undefined name 'io'
6
```
__E901,E999,F821,F822,F823__ are the "_showstopper_" [flake8](http://flake8.pycqa.org) issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety.
* F821: undefined name `name`
* F822: undefined name `name` in `__all__`
* F823: local variable name referenced before assignment
* E901: SyntaxError or IndentationError
* E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
@greysteil
Copy link
Contributor

Thanks for this!

@greysteil greysteil merged commit 1696318 into dependabot:master Sep 10, 2019
@cclauss cclauss deleted the patch-1 branch September 10, 2019 11:22
cclauss added a commit to cclauss/dependabot-core that referenced this pull request Sep 10, 2019
Use [GitHub Actions CI](https://github.com/features/actions) to find undefined names in Python code like the ones that were fixed in dependabot#1219

Based on https://github.com/actions/starter-workflows/actions/new
cclauss added a commit to cclauss/dependabot-core that referenced this pull request Sep 10, 2019
Like dependabot#1375 but without GitHub Actions.  Find syntax errors and undefined names in Python code like the ones fixed in dependabot#1219.
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 this pull request may close these issues.

2 participants