Skip to content

F401 (imported but unused) false positive on Foo when using def x(a: Foo, /, *, b: Bar) #507

Closed

Description

@mikeholler
from datetime import datetime as Foo, time as Bar


def x(a: Foo, /, *, b: Bar):
    pass

Running this on the file results in:

› flake8 --version  
3.7.9 (mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.8.1 on Linux
› pyflakes --version
2.1.1 Python 3.8.1 on Linux
› flake8 example.py 
example.py:1:1: F401 'datetime.datetime as Foo' imported but unused
› pyflakes example.py
example.py:1: 'datetime.datetime as Foo' imported but unused

Activity

  1. asottile commented on Jan 17, 2020

    @asottile
    Member

    confirmed. #508 contains a fix -- please review the code change / validate the fix if you can (pyflakes has a 2-reviewer sign off which can make it difficult to land changes)

  2. changed the title [-]F401 (imported but unused) false positive on Bar when using def x(a: Foo, /, *, b: Bar)[/-] [+]F401 (imported but unused) false positive on Foo when using def x(a: Foo, /, *, b: Bar)[/+] on Jan 17, 2020
  3. mikeholler commented on Jan 17, 2020

    @mikeholler
    Author

    WOW this is fast. I will try to get to it in the next couple hours. How do we get it into flake8?

  4. asottile commented on Jan 17, 2020

    @asottile
    Member

    until both pyflakes and flake8 make their next release the only option for getting this changeset through flake8 is to install pyflakes from git alongside flake8 -- you can do that through pip install git+https://github.com/pycqa/pyflakes@revision_here -- if you're using this through pre-commit for some reason you need -e git+... 🤷‍♂️

  5. asottile commented on Jan 17, 2020

    @asottile
    Member

    additionally if you have some spare cycles, reviewing some of the other open PRs would be greatly appreciated 🙏

  6. mikeholler commented on Jan 17, 2020

    @mikeholler
    Author

    Okay signed off on this one. I'll keep the need for review in mind for the future. Right now I'm working more than I have in a long time, no cycles to spare. I'll keep this in mind after the deadline passes, though.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions