Skip to content
Open
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: 2 additions & 0 deletions stubs/pyflakes/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# These all have class-level defaults that differ from the instance attributes
pyflakes.messages.DuplicateArgument.message_args
pyflakes.messages.EagerUseOfLazyImport.message_args
pyflakes.messages.ForwardAnnotationSyntaxError.message_args
pyflakes.messages.FutureFeatureNotDefined.message_args
pyflakes.messages.ImportShadowedByLoopVar.message_args
pyflakes.messages.ImportStarNotPermitted.message_args
pyflakes.messages.ImportStarUsage.message_args
pyflakes.messages.ImportStarUsed.message_args
pyflakes.messages.LazyImportStarNotPermitted.message_args
pyflakes.messages.MultiValueRepeatedKeyLiteral.message_args
pyflakes.messages.MultiValueRepeatedKeyVariable.message_args
pyflakes.messages.PercentFormatExtraNamedArguments.message_args
Expand Down
2 changes: 1 addition & 1 deletion stubs/pyflakes/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "3.4.*"
version = "4.0.*"
upstream-repository = "https://github.com/PyCQA/pyflakes"
52 changes: 24 additions & 28 deletions stubs/pyflakes/pyflakes/checker.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ast
import sys
from _typeshed import StrOrLiteralStr, Unused
from _typeshed import StrOrLiteralStr
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from contextlib import contextmanager
from re import Pattern
Expand All @@ -13,7 +13,7 @@ _F = TypeVar("_F", bound=Callable[..., Any])
_P = ParamSpec("_P")

PYPY: Final[bool]
builtin_vars: Final[list[str]]
builtin_vars: Final[frozenset[str]]

def parse_format_string(
format_string: StrOrLiteralStr,
Expand All @@ -33,12 +33,10 @@ _PercentFormat: TypeAlias = tuple[str, _FormatType | None]

def parse_percent_format(s: str) -> tuple[_PercentFormat, ...]: ...

class _FieldsOrder(dict[type[ast.AST], tuple[str, ...]]):
def __missing__(self, node_class: type[ast.AST]) -> tuple[str, ...]: ...

_OmitType: TypeAlias = str | tuple[str, ...] | None

def iter_child_nodes(node: ast.AST, omit: _OmitType = None, _fields_order: _FieldsOrder = ...) -> Iterator[ast.AST]: ...
def iter_child_nodes(node: ast.AST, omit: _OmitType = None) -> Iterator[ast.AST]: ...
def iter_dict_children(node: ast.Dict) -> Iterable[tuple[ast.expr | None, ast.expr]]: ...

@overload
def convert_to_value(item: ast.Constant) -> Any: ... # type: ignore[overload-overlap] # See ast.Constant.value for possible return types
Expand Down Expand Up @@ -74,17 +72,20 @@ class VariableKey:
class Importation(Definition):
fullName: str
redefined: list[ast.AST]
def __init__(self, name: str, source: ast.AST | None, full_name: str | None = None) -> None: ...
is_lazy: int
def __init__(self, name: str, source: ast.AST | None, full_name: str | None = None, *, is_lazy: int) -> None: ...
@property
def imported_name(self) -> str: ...
@property
def source_statement(self) -> str: ...

class SubmoduleImportation(Importation):
def __init__(self, name: str, source: ast.Import | None) -> None: ...
def __init__(self, name: str, source: ast.Import | None, *, is_lazy: int) -> None: ...

class ImportationFrom(Importation):
module: str
real_name: str
def __init__(self, name: str, source: ast.AST, module: str, real_name: str | None = None) -> None: ...
def __init__(self, name: str, source: ast.AST, module: str, real_name: str | None = None, *, is_lazy: int) -> None: ...

class StarImportation(Importation):
def __init__(self, name: str, source: ast.AST) -> None: ...
Expand All @@ -111,20 +112,20 @@ class Scope(dict[str, Binding]):
importStarred: bool

class ClassScope(Scope):
indirect_assignments: dict[str, ast.Global | ast.Nonlocal]
def __init__(self) -> None: ...

class FunctionScope(Scope):
usesLocals: bool
alwaysUsed: ClassVar[set[str]]
globals: set[str]
returnValue: ast.expr | None
isGenerator: bool
always_used: ClassVar[frozenset[str]]
indirect_assignments: dict[str, ast.Global | ast.Nonlocal]
def __init__(self) -> None: ...
def unused_assignments(self) -> Iterator[tuple[str, Binding]]: ...
def unused_annotations(self) -> Iterator[tuple[str, Annotation]]: ...

class TypeScope(Scope): ...
class GeneratorScope(Scope): ...
class ComprehensionScope(Scope): ...
class GeneratorScope(ComprehensionScope): ...
class ModuleScope(Scope): ...
class DoctestScope(ModuleScope): ...

Expand All @@ -141,6 +142,7 @@ class AnnotationState:
NONE: ClassVar[Literal[0]]
STRING: ClassVar[Literal[1]]
BARE: ClassVar[Literal[2]]
STR_AS_TYPE: ClassVar[Literal[3]]

def in_annotation(func: _F) -> _F: ...
def in_string_annotation(func: _F) -> _F: ...
Expand Down Expand Up @@ -170,7 +172,7 @@ else:
class Checker:
nodeDepth: int
offset: tuple[int, int] | None
builtIns: set[str]
builtIns: frozenset[str]
deadScopes: list[Scope]
messages: list[Message]
filename: str
Expand All @@ -179,12 +181,7 @@ class Checker:
exceptHandlers: list[tuple[()] | str]
root: ast.AST
def __init__(
self,
tree: ast.AST,
filename: str = "(none)",
builtins: Iterable[str] | None = None,
withDoctest: bool = False,
file_tokens: Unused = (),
self, tree: ast.AST, filename: str = "(none)", builtins: Iterable[str] | None = None, withDoctest: bool = False
) -> None: ...
def deferFunction(self, callable: Callable[..., Any]) -> None: ...

Expand All @@ -207,7 +204,6 @@ class Checker:
def getParent(self, node: ast.AST) -> ast.AST: ...
def getCommonAncestor(self, lnode: ast.AST, rnode: ast.AST, stop: ast.AST) -> ast.AST: ...
def descendantOf(self, node: ast.AST, ancestors: ast.AST, stop: ast.AST) -> bool: ...
def getScopeNode(self, node: ast.AST) -> ast.AST | None: ...
def differentForks(self, lnode: ast.AST, rnode: ast.AST) -> bool: ...
def addBinding(self, node: ast.AST, value: Binding) -> None: ...
def getNodeHandler(self, node_class: type[ast.AST]) -> Callable[[ast.AST], None]: ...
Expand All @@ -220,27 +216,27 @@ class Checker:
def getDocstring(self, node: ast.AST) -> tuple[str, int] | tuple[None, None]: ...
def handleNode(self, node: ast.AST | None, parent: ast.AST | None) -> None: ...
def handleDoctests(self, node: ast.AST) -> None: ...
def handleStringAnnotation(self, s: str, node: ast.AST, ref_lineno: int, ref_col_offset: int, err: type[Message]) -> None: ...
def handleStringAnnotation(self, s: str, node: ast.AST, ref_lineno: int, ref_col_offset: int) -> None: ...
def handle_annotation_always_deferred(self, annotation: ast.AST, parent: ast.AST) -> None: ...
def handleAnnotation(self, annotation: ast.AST, node: ast.AST) -> None: ...
def ignore(self, node: ast.AST) -> None: ...
def DELETE(self, tree: ast.Delete, omit: _OmitType = None) -> None: ...
def FOR(self, tree: ast.For, omit: _OmitType = None) -> None: ...
def ASYNCFOR(self, tree: ast.AsyncFor, omit: _OmitType = None) -> None: ...
def FOR(self, node: ast.For) -> None: ...
def ASYNCFOR(self, node: ast.AsyncFor) -> None: ...
def WHILE(self, tree: ast.While, omit: _OmitType = None) -> None: ...
def WITH(self, tree: ast.With, omit: _OmitType = None) -> None: ...
def WITHITEM(self, tree: ast.AST, omit: _OmitType = None) -> None: ...
def ASYNCWITH(self, tree: ast.AsyncWith, omit: _OmitType = None) -> None: ...
def EXPR(self, tree: ast.AST, omit: _OmitType = None) -> None: ...
def ASSIGN(self, tree: ast.Assign, omit: _OmitType = None) -> None: ...
def ASSIGN(self, node: ast.Assign) -> None: ...
def PASS(self, node: ast.AST) -> None: ...
def BOOLOP(self, tree: ast.BoolOp, omit: _OmitType = None) -> None: ...
def UNARYOP(self, tree: ast.UnaryOp, omit: _OmitType = None) -> None: ...
def SET(self, tree: ast.Set, omit: _OmitType = None) -> None: ...
def ATTRIBUTE(self, tree: ast.Attribute, omit: _OmitType = None) -> None: ...
def STARRED(self, tree: ast.Starred, omit: _OmitType = None) -> None: ...
def NAMECONSTANT(self, tree: _NameConstant, omit: _OmitType = None) -> None: ...
def NAMEDEXPR(self, tree: ast.NamedExpr, omit: _OmitType = None) -> None: ...
def NAMEDEXPR(self, node: ast.NamedExpr) -> None: ...
def SUBSCRIPT(self, node: ast.Subscript) -> None: ...
def CALL(self, node: ast.Call) -> None: ...
def BINOP(self, node: ast.BinOp) -> None: ...
Expand Down Expand Up @@ -284,7 +280,7 @@ class Checker:
def NOTIN(self, node: ast.NotIn) -> None: ...
def MATMULT(self, node: ast.MatMult) -> None: ...
def RAISE(self, node: ast.Raise) -> None: ...
def COMPREHENSION(self, tree: ast.comprehension, omit: _OmitType = None) -> None: ...
def COMPREHENSION(self, node: ast.comprehension) -> None: ...
def KEYWORD(self, tree: ast.keyword, omit: _OmitType = None) -> None: ...
def FORMATTEDVALUE(self, tree: ast.FormattedValue, omit: _OmitType = None) -> None: ...
def JOINEDSTR(self, node: ast.AST) -> None: ...
Expand Down
12 changes: 11 additions & 1 deletion stubs/pyflakes/pyflakes/messages.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class UndefinedName(Message):

class DoctestSyntaxError(Message):
message_args: tuple[()]
def __init__(self, filename: str, loc: ast.AST, position: tuple[int, int] | None = None) -> None: ...
def __init__(self, filename: str, loc: ast.AST, position: tuple[int, int]) -> None: ...

class UndefinedExport(Message):
message_args: tuple[str]
Expand Down Expand Up @@ -146,3 +146,13 @@ class PercentFormatMissingArgument(Message):
class PercentFormatExpectedMapping(Message): ...
class PercentFormatExpectedSequence(Message): ...
class PercentFormatStarRequiresSequence(Message): ...

class EagerUseOfLazyImport(Message):
message_args: tuple[str, int]
def __init__(self, filename: str, loc: ast.AST, name: str, orig_loc: ast.AST) -> None: ...

class LazyImportStarNotPermitted(Message):
message_args: tuple[str]
def __init__(self, filename: str, loc: ast.AST, modname: str) -> None: ...

class LazyImportNotAtModuleScope(Message): ...
Loading