From 489be4d30a37273e67683d14758e3a7912d46571 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 23 Nov 2022 13:56:50 -0500 Subject: [PATCH] upgrade pyflakes to 3.0.0 --- setup.cfg | 2 +- src/flake8/plugins/pyflakes.py | 17 +++-------------- tests/unit/plugins/finder_test.py | 2 +- tests/unit/test_pyflakes_codes.py | 2 +- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/setup.cfg b/setup.cfg index d2959c84..6c28b909 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,7 +36,7 @@ package_dir = install_requires = mccabe>=0.7.0,<0.8.0 pycodestyle>=2.10.0,<2.11.0 - pyflakes>=2.5.0,<2.6.0 + pyflakes>=3.0.0,<3.1.0 # 3.8.0's importlib.metadata is broken python_requires = >=3.8.1 diff --git a/src/flake8/plugins/pyflakes.py b/src/flake8/plugins/pyflakes.py index cffea362..a9dbc4c1 100644 --- a/src/flake8/plugins/pyflakes.py +++ b/src/flake8/plugins/pyflakes.py @@ -4,7 +4,6 @@ import argparse import ast import os -import tokenize from typing import Any from typing import Generator @@ -52,13 +51,13 @@ "DefaultExceptNotLast": "F707", "DoctestSyntaxError": "F721", "ForwardAnnotationSyntaxError": "F722", - "CommentAnnotationSyntaxError": "F723", "RedefinedWhileUnused": "F811", "UndefinedName": "F821", "UndefinedExport": "F822", "UndefinedLocal": "F823", "DuplicateArgument": "F831", "UnusedVariable": "F841", + "UnusedAnnotation": "F842", "RaiseNotImplemented": "F901", } @@ -70,12 +69,7 @@ class FlakesChecker(pyflakes.checker.Checker): include_in_doctest: list[str] = [] exclude_from_doctest: list[str] = [] - def __init__( - self, - tree: ast.AST, - file_tokens: list[tokenize.TokenInfo], - filename: str, - ) -> None: + def __init__(self, tree: ast.AST, filename: str) -> None: """Initialize the PyFlakes plugin with an AST tree and filename.""" filename = utils.normalize_path(filename) with_doctest = self.with_doctest @@ -99,12 +93,7 @@ def __init__( if overlapped_by: with_doctest = True - super().__init__( - tree, - filename=filename, - withDoctest=with_doctest, - file_tokens=file_tokens, - ) + super().__init__(tree, filename=filename, withDoctest=with_doctest) @classmethod def add_options(cls, parser: OptionManager) -> None: diff --git a/tests/unit/plugins/finder_test.py b/tests/unit/plugins/finder_test.py index 89de0a7a..b289befa 100644 --- a/tests/unit/plugins/finder_test.py +++ b/tests/unit/plugins/finder_test.py @@ -685,7 +685,7 @@ def test_load_plugin_ok(): assert loaded == finder.LoadedPlugin( plugin, FlakesChecker, - {"tree": True, "file_tokens": True, "filename": True}, + {"tree": True, "filename": True}, ) diff --git a/tests/unit/test_pyflakes_codes.py b/tests/unit/test_pyflakes_codes.py index 4626e3d0..444008a2 100644 --- a/tests/unit/test_pyflakes_codes.py +++ b/tests/unit/test_pyflakes_codes.py @@ -27,7 +27,7 @@ def f(): sys = sys """ tree = ast.parse(src) - checker = pyflakes_shim.FlakesChecker(tree, [], "t.py") + checker = pyflakes_shim.FlakesChecker(tree, "t.py") message_texts = [s for _, _, s, _ in checker.run()] assert message_texts == [ "F823 local variable 'sys' defined in enclosing scope on line 1 referenced before assignment", # noqa: E501