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

Wrong F401 error raised #747

Closed
ocelotl opened this issue Nov 24, 2022 · 4 comments
Closed

Wrong F401 error raised #747

ocelotl opened this issue Nov 24, 2022 · 4 comments
Labels

Comments

@ocelotl
Copy link

ocelotl commented Nov 24, 2022

This seems like a regression of #247. The example below uses nox.

I created a directory with three files:

module_a.py  module_b.py  noxfile.py

module_a.py:

class ClassA:
    pass

module_b.py:

from module_a import ClassA


for _ in range(4):  # type: ClassA
    print(0)

noxfile.py:

from nox import session


@session(python=["3.10"])
def lint(session):
    session.install("flake8==5.0.4")
    # session.install("flake8==6.0.0")
    session.run("flake8", "--version")
    session.run("flake8")

When I run nox, no issues are raised:

nox > Running session lint-3.10
nox > Creating virtual environment (virtualenv) using python3.10 in .nox/lint-3-10
nox > python -m pip install flake8==5.0.4
nox > flake8 --version
5.0.4 (mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.10.4 on Linux
nox > flake8 
nox > Session lint-3.10 was successful.

When I uncomment # session.install("flake8==6.0.0"), comment session.install("flake8==5.0.4") and run nox again, an issue is raised:

nox > Running session lint-3.10
nox > Creating virtual environment (virtualenv) using python3.10 in .nox/lint-3-10
nox > python -m pip install flake8==6.0.0
nox > flake8 --version
6.0.0 (mccabe: 0.7.0, pycodestyle: 2.10.0, pyflakes: 3.0.1) CPython 3.10.4 on Linux
nox > flake8 
./module_b.py:1:1: F401 'module_a.ClassA' imported but unused
nox > Command flake8  failed with exit code 1
nox > Session lint-3.10 failed.
@asottile
Copy link
Member

@ocelotl please (1) search the issue tracker and (2) read the changelog for 3.0.0

@ikapelyukhin
Copy link

 3.0.0 (2022-11-23)

    [...]
    Remove handling of python 2.x # type: comments. Use annotations instead

tych0 added a commit to tych0/qtile that referenced this issue Nov 29, 2022
pyflakes 3.0.0 drops support for the comment style annotations, in favor of
the actual syntactic version of type annotations.

This gets everything to pass flake8 again, but there are still many
instances of " # type" that we should fix.

PyCQA/pyflakes#747 (comment)
tych0 added a commit to qtile/qtile that referenced this issue Nov 29, 2022
pyflakes 3.0.0 drops support for the comment style annotations, in favor of
the actual syntactic version of type annotations.

This gets everything to pass flake8 again, but there are still many
instances of " # type" that we should fix.

PyCQA/pyflakes#747 (comment)
tych0 added a commit to tych0/qtile that referenced this issue Nov 29, 2022
pyflakes 3.0.0 drops support for the comment style annotations, in favor of
the actual syntactic version of type annotations.

This gets everything to pass flake8 again, but there are still many
instances of " # type" that we should fix.

PyCQA/pyflakes#747 (comment)

Signed-off-by: Tycho Andersen <[email protected]>
tych0 added a commit to qtile/qtile that referenced this issue Nov 29, 2022
pyflakes 3.0.0 drops support for the comment style annotations, in favor of
the actual syntactic version of type annotations.

This gets everything to pass flake8 again, but there are still many
instances of " # type" that we should fix.

PyCQA/pyflakes#747 (comment)

Signed-off-by: Tycho Andersen <[email protected]>
elParaguayo pushed a commit to qtile/qtile that referenced this issue Nov 29, 2022
pyflakes 3.0.0 drops support for the comment style annotations, in favor of
the actual syntactic version of type annotations.

This gets everything to pass flake8 again, but there are still many
instances of " # type" that we should fix.

PyCQA/pyflakes#747 (comment)

Signed-off-by: Tycho Andersen <[email protected]>
lengau added a commit to lengau/snapcraft that referenced this issue Dec 15, 2022
* Add tox >= 4.0 as a dev dependency
* Add tox configuration to setup.cfg
  - I chose setup.cfg because pyproject.toml support in tox is awkward (tox-dev/tox#999)
  - Specified flake8 < 6.0.0 until we can get around to replacing type comments with type annotations.
    PyCQA/pyflakes#747
* Modify Makefile to use tox instead of running the commands directly
* Update .gitignore for relevant new files and directories
* Update requirements files
  - Newer tarball in freeze-requirements.sh because the older one was sometimes breaking in tox.
* Set pylint configuration to ignore tests/legacy rather than manually excluding it

A future commit will configure tox in Github actions.
@rchl
Copy link

rchl commented Dec 29, 2022

Was this change made knowing full well that it's only possible to use annotations for variables from python 3.6 and up?

I'm asking since the commit message (Remove handling of python 2.x # type: comments) doesn't make it clear that this was intentional.

@asottile
Copy link
Member

pyflakes only supports python3.6 and above

@PyCQA PyCQA locked as resolved and limited conversation to collaborators Dec 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants