mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
upgrade pyflakes to 3.0.0
This commit is contained in:
parent
8c06197cd5
commit
489be4d30a
4 changed files with 6 additions and 17 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||
import argparse
|
||||
import ast
|
||||
import os
|
||||
import tokenize
|
||||
from typing import Any
|
||||
from typing import Generator
|
||||
|
||||
|
|
@ -52,13 +51,13 @@ FLAKE8_PYFLAKES_CODES = {
|
|||
"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 @@ class FlakesChecker(pyflakes.checker.Checker):
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue