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

F821 undefined name gives wrong line number (alwasy line 1) when variable is in an f-string #562

Closed
asottile opened this issue Apr 3, 2021 · 10 comments

Comments

@asottile
Copy link
Member

asottile commented Apr 3, 2021

In GitLab by @samuelcolvin on Feb 22, 2017, 06:07

setup:

➤  flake8 --bug-report
{
  "dependencies": [
    {
      "dependency": "setuptools",
      "version": "34.2.0"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.0+",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.3.1"
    },
    {
      "plugin": "pyflakes",
      "version": "1.5.0"
    }
  ],
  "version": "3.3.0"
}

foobar.py:

a = 'this is a test'
b = f'this is a good fstring: {a}'
c = f'this is a bad fstring: {abc}'
➤  flake8 foobar.py 
foobar.py:1:2: F821 undefined name 'abc'

You would expect the error to say line 3 not line 1.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @samuelcolvin on Feb 22, 2017, 06:10

sorry, realised this should have been posted to pyflakes.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @samuelcolvin on Feb 22, 2017, 06:10

closed

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @samuelcolvin on Feb 22, 2017, 06:18

Error in pyflakes it slightly different, I'm now a bit confused about whether this should be posted here or on the pyflakes' launchpad.

I'll leave it open here, let me know if you want me to close here and resubmit elsewhere.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @samuelcolvin on Feb 22, 2017, 06:18

reopened

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Feb 22, 2017, 06:27

So https://bugs.launchpad.net/pyflakes/+bug/1666811 was reported this morning. PyFlakes doesn't report columns so the error may be slightly dissimilar. That said, this is definitely a bug in pyflakes.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @samuelcolvin on Feb 22, 2017, 06:29

Thanks, sorry for missing that. I'm guessing you want the issue left open until it's fixed upstream?

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @blueyed on Feb 15, 2018, 16:18

According to https://bugs.launchpad.net/pyflakes/+bug/1666811/comments/3 this is fixed/improved with Python 3.6.3.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Oct 20, 2018, 10:17

closed

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on Oct 2, 2020, 16:37

changed the description

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

1 participant