From a079b0de6e703fcb615a1169a32bc2186efee9bd Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 30 Jul 2023 23:35:26 +0100 Subject: [PATCH] Update pyflakes stubs for v3.1.* (#10518) --- stubs/pyflakes/METADATA.toml | 2 +- stubs/pyflakes/pyflakes/checker.pyi | 25 ++++++++++++++----------- stubs/pyflakes/pyflakes/messages.pyi | 1 - 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/stubs/pyflakes/METADATA.toml b/stubs/pyflakes/METADATA.toml index 7e4226433..4e2e82587 100644 --- a/stubs/pyflakes/METADATA.toml +++ b/stubs/pyflakes/METADATA.toml @@ -1,4 +1,4 @@ -version = "3.0.*" +version = "3.1.*" upstream_repository = "https://github.com/PyCQA/pyflakes" partial_stub = true diff --git a/stubs/pyflakes/pyflakes/checker.pyi b/stubs/pyflakes/pyflakes/checker.pyi index 4bf58bc5b..11262b692 100644 --- a/stubs/pyflakes/pyflakes/checker.pyi +++ b/stubs/pyflakes/pyflakes/checker.pyi @@ -1,6 +1,7 @@ import ast import sys from collections.abc import Callable, Iterable, Iterator +from contextlib import contextmanager from re import Pattern from typing import Any, ClassVar, TypeVar, overload from typing_extensions import Literal, ParamSpec, TypeAlias @@ -12,7 +13,6 @@ _F = TypeVar("_F", bound=_AnyFunction) _P = ParamSpec("_P") _T = TypeVar("_T") -PY38_PLUS: bool PYPY: bool def getAlternatives(n: ast.If | ast.Try) -> list[ast.AST]: ... @@ -120,6 +120,7 @@ class FunctionScope(Scope): def unused_assignments(self) -> Iterator[tuple[str, Binding]]: ... def unused_annotations(self) -> Iterator[tuple[str, Annotation]]: ... +class TypeScope(Scope): ... class GeneratorScope(Scope): ... class ModuleScope(Scope): ... class DoctestScope(ModuleScope): ... @@ -169,6 +170,13 @@ else: _MatchAs: TypeAlias = Any _MatchOr: TypeAlias = Any +if sys.version_info >= (3, 12): + _TypeVar: TypeAlias = ast.TypeVar + _TypeAlias: TypeAlias = ast.TypeAlias +else: + _TypeVar: TypeAlias = Any + _TypeAlias: TypeAlias = Any + class Checker: nodeDepth: int offset: tuple[int, int] | None @@ -189,8 +197,6 @@ class Checker: file_tokens: tuple[Any, ...] = (), ) -> None: ... def deferFunction(self, callable: _AnyFunction) -> None: ... - def deferAssignment(self, callable: _AnyFunction) -> None: ... - def runDeferred(self, deferred: _AnyFunction) -> None: ... @property def futuresAllowed(self) -> bool: ... @futuresAllowed.setter @@ -201,9 +207,9 @@ class Checker: def annotationsFutureEnabled(self, value: Literal[True]) -> None: ... @property def scope(self) -> Scope: ... - def popScope(self) -> None: ... + @contextmanager + def in_scope(self, cls: Callable[[], Scope]) -> Iterator[None]: ... def checkDeadScopes(self) -> None: ... - def pushScope(self, scopeClass: type[Scope] = ...) -> None: ... def report(self, messageClass: Callable[_P, Message], *args: _P.args, **kwargs: _P.kwargs) -> None: ... def getParent(self, node: ast.AST) -> ast.AST: ... def getCommonAncestor(self, lnode: ast.AST, rnode: ast.AST, stop: ast.AST) -> ast.AST: ... @@ -222,6 +228,7 @@ class Checker: def handleNode(self, node: ast.AST | None, parent) -> 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 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: ... @@ -245,12 +252,6 @@ class Checker: def CALL(self, node: ast.Call) -> None: ... def BINOP(self, node: ast.BinOp) -> None: ... def CONSTANT(self, node: ast.Constant) -> None: ... - if sys.version_info < (3, 8): - def NUM(self, node: ast.Num) -> None: ... - def BYTES(self, node: ast.Bytes) -> None: ... - def ELLIPSIS(self, node: ast.Ellipsis) -> None: ... - - def STR(self, node: ast.Str) -> None: ... def SLICE(self, tree: ast.Slice, omit: _OmitType = None) -> None: ... def EXTSLICE(self, tree: ast.ExtSlice, omit: _OmitType = None) -> None: ... def INDEX(self, tree: ast.Index, omit: _OmitType = None) -> None: ... @@ -336,3 +337,5 @@ class Checker: def MATCHAS(self, node: _MatchAs) -> None: ... def MATCHMAPPING(self, node: _MatchMapping) -> None: ... def MATCHSTAR(self, node: _MatchStar) -> None: ... + def TYPEVAR(self, node: _TypeVar) -> None: ... + def TYPEALIAS(self, node: _TypeAlias) -> None: ... diff --git a/stubs/pyflakes/pyflakes/messages.pyi b/stubs/pyflakes/pyflakes/messages.pyi index c0b3b0d65..07371e582 100644 --- a/stubs/pyflakes/pyflakes/messages.pyi +++ b/stubs/pyflakes/pyflakes/messages.pyi @@ -83,7 +83,6 @@ class ReturnOutsideFunction(Message): ... class YieldOutsideFunction(Message): ... class ContinueOutsideLoop(Message): ... class BreakOutsideLoop(Message): ... -class ContinueInFinally(Message): ... class DefaultExceptNotLast(Message): ... class TwoStarredExpressions(Message): ... class TooManyExpressionsInStarredAssignment(Message): ...