Skip to content

Commit

Permalink
Merge pull request #1748 from PyCQA/upgrade-pyflakes
Browse files Browse the repository at this point in the history
upgrade pyflakes to 3.0.0
  • Loading branch information
asottile authored Nov 23, 2022
2 parents 8c06197 + 489be4d commit b5cac87
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 3 additions & 14 deletions src/flake8/plugins/pyflakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import argparse
import ast
import os
import tokenize
from typing import Any
from typing import Generator

Expand Down Expand Up @@ -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",
}

Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/finder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_pyflakes_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b5cac87

Please sign in to comment.