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

upgrade pyflakes to 3.0.0 #1748

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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