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

global/local syntax errors not caught #249

Open
pyflakes-bot opened this issue Jun 8, 2016 · 3 comments
Open

global/local syntax errors not caught #249

pyflakes-bot opened this issue Jun 8, 2016 · 3 comments

Comments

@pyflakes-bot
Copy link

Original report by asmeurer (@asmeurer?) on Launchpad:


This is perhaps a bit obscure, but here's a class of syntax errors that aren't caught by pyflakes

$ cat test.py
def test(x):
    global x
$ pyflakes test.py
$ python test.py
  File "test.py", line 2
    global x
SyntaxError: name 'x' is parameter and global

I'm unsure what the full set of possible errors are here. One would need to check the Python source. I know there are some others relating to the Python 3 "nonlocal" keyword as well.

@asmeurer
Copy link
Contributor

asmeurer commented Nov 4, 2017

Just hit the nonlocal one. Would definitely be nice if pyflakes properly warned about these.

seeeturtle added a commit to seeeturtle/pyflakes that referenced this issue Jan 17, 2018
seeeturtle added a commit to seeeturtle/pyflakes that referenced this issue Jan 17, 2018
seeeturtle added a commit to seeeturtle/pyflakes that referenced this issue Jan 17, 2018
When we use undefined name declared by global statement,
pyflakes should catch the error but it doesn't.
This will fix pyflakes to catch this error.
Check test_undefined_globa

Fixes PyCQA#249
seeeturtle added a commit to seeeturtle/pyflakes that referenced this issue Jan 17, 2018
When we use undefined name declared by global statement,
pyflakes should catch the error but it doesn't.
This will fix pyflakes to catch this error.
Check test_undefined_globa

Fixes PyCQA#249
@asmeurer
Copy link
Contributor

asmeurer commented Feb 8, 2019

Another related one is nonlocal after a variable definition

$ cat test2.py
def test():
    a = 2
    nonlocal a
$ python test2.py
  File "test2.py", line 3
    nonlocal a
    ^
SyntaxError: name 'a' is assigned to before nonlocal declaration
$ pyflakes test2.py # no errors

@vkrmjeet

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants