Skip to content
2 changes: 1 addition & 1 deletion pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"stubs/**/@tests/test_cases",
"stdlib/distutils/command",
"stdlib/distutils/dist.pyi",
"stdlib/lib2to3/refactor.pyi",
"stdlib/lib2to3/fixes/*.pyi",
"stdlib/_tkinter.pyi",
"stdlib/tkinter/__init__.pyi",
"stdlib/tkinter/filedialog.pyi",
Expand Down
28 changes: 28 additions & 0 deletions stdlib/lib2to3/btm_matcher.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from _typeshed import Incomplete, SupportsGetItem
from collections import defaultdict
from collections.abc import Iterable

from .fixer_base import BaseFix
from .pytree import Leaf, Node

class BMNode:
count: Incomplete
transition_table: Incomplete
fixers: Incomplete
id: Incomplete
content: str
def __init__(self) -> None: ...

class BottomMatcher:
match: Incomplete
root: Incomplete
nodes: Incomplete
fixers: Incomplete
logger: Incomplete
def __init__(self) -> None: ...
def add_fixer(self, fixer: BaseFix) -> None: ...
def add(self, pattern: SupportsGetItem[int | slice, Incomplete] | None, start: BMNode) -> list[BMNode]: ...
def run(self, leaves: Iterable[Leaf]) -> defaultdict[BaseFix, list[Node | Leaf]]: ...
def print_ac(self) -> None: ...

def type_repr(type_num: int) -> str | int: ...
43 changes: 43 additions & 0 deletions stdlib/lib2to3/fixer_base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from _typeshed import Incomplete, StrPath
from abc import ABCMeta, abstractmethod
from collections.abc import MutableMapping
from typing import ClassVar, TypeVar
from typing_extensions import Literal

from .pytree import Base, Leaf, Node

_N = TypeVar("_N", bound=Base)

class BaseFix:
PATTERN: ClassVar[str | None]
pattern: Incomplete | None
pattern_tree: Incomplete | None
options: Incomplete | None
filename: Incomplete | None
numbers: Incomplete
used_names: Incomplete
order: ClassVar[Literal["post", "pre"]]
explicit: ClassVar[bool]
run_order: ClassVar[int]
keep_line_order: ClassVar[bool]
BM_compatible: ClassVar[bool]
syms: Incomplete
log: Incomplete
def __init__(self, options: MutableMapping[str, Incomplete], log: list[str]) -> None: ...
def compile_pattern(self) -> None: ...
def set_filename(self, filename: StrPath) -> None: ...
def match(self, node: _N) -> Literal[False] | dict[str, _N]: ...
@abstractmethod
def transform(self, node: Base, results: dict[str, Base]) -> Node | Leaf | None: ...
def new_name(self, template: str = "xxx_todo_changeme") -> str: ...
first_log: bool
def log_message(self, message: str) -> None: ...
def cannot_convert(self, node: Base, reason: str | None = None) -> None: ...
def warning(self, node: Base, reason: str) -> None: ...
def start_tree(self, tree: Node, filename: StrPath) -> None: ...
def finish_tree(self, tree: Node, filename: StrPath) -> None: ...

class ConditionalFix(BaseFix, metaclass=ABCMeta):
skip_on: ClassVar[str | None]
def start_tree(self, __tree: Node, __filename: StrPath) -> None: ...
def should_skip(self, node: Base) -> bool: ...
Empty file.
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_apply.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixApply(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
11 changes: 11 additions & 0 deletions stdlib/lib2to3/fixes/fix_asserts.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from typing import ClassVar
from typing_extensions import Literal

from ..fixer_base import BaseFix

NAMES: dict[str, str]

class FixAsserts(BaseFix):
BM_compatible: ClassVar[Literal[False]]
PATTERN: ClassVar[str]
def transform(self, node, results) -> None: ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_basestring.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixBasestring(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[Literal["'basestring'"]]
def transform(self, node, results): ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_buffer.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixBuffer(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results) -> None: ...
17 changes: 17 additions & 0 deletions stdlib/lib2to3/fixes/fix_dict.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from _typeshed import Incomplete
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

iter_exempt: set[str]

class FixDict(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
P1: ClassVar[str]
p1: ClassVar[Incomplete]
P2: ClassVar[str]
p2: ClassVar[Incomplete]
def in_special_context(self, node, isiter): ...
15 changes: 15 additions & 0 deletions stdlib/lib2to3/fixes/fix_except.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from collections.abc import Generator, Iterable
from typing import ClassVar, TypeVar
from typing_extensions import Literal

from .. import fixer_base
from ..pytree import Base

_N = TypeVar("_N", bound=Base)

def find_excepts(nodes: Iterable[_N]) -> Generator[tuple[_N, _N], None, None]: ...

class FixExcept(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_exec.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixExec(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_execfile.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixExecfile(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
14 changes: 14 additions & 0 deletions stdlib/lib2to3/fixes/fix_exitfunc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from _typeshed import Incomplete, StrPath
from lib2to3 import fixer_base
from typing import ClassVar
from typing_extensions import Literal

from ..pytree import Node

class FixExitfunc(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def __init__(self, *args) -> None: ...
sys_import: Incomplete | None
def start_tree(self, tree: Node, filename: StrPath) -> None: ...
def transform(self, node, results) -> None: ...
10 changes: 10 additions & 0 deletions stdlib/lib2to3/fixes/fix_filter.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixFilter(fixer_base.ConditionalFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
skip_on: ClassVar[Literal["future_builtins.filter"]]
def transform(self, node, results): ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_funcattrs.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixFuncattrs(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results) -> None: ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_future.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixFuture(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_getcwdu.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixGetcwdu(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results) -> None: ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_has_key.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixHasKey(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
16 changes: 16 additions & 0 deletions stdlib/lib2to3/fixes/fix_idioms.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

CMP: str
TYPE: str

class FixIdioms(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[False]]
PATTERN: ClassVar[str]
def match(self, node): ...
def transform(self, node, results): ...
def transform_isinstance(self, node, results): ...
def transform_while(self, node, results) -> None: ...
def transform_sort(self, node, results) -> None: ...
17 changes: 17 additions & 0 deletions stdlib/lib2to3/fixes/fix_import.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from _typeshed import StrPath
from collections.abc import Generator
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base
from ..pytree import Node

def traverse_imports(names) -> Generator[str, None, None]: ...

class FixImport(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
skip: bool
def start_tree(self, tree: Node, name: StrPath) -> None: ...
def transform(self, node, results): ...
def probably_a_local_import(self, imp_name): ...
22 changes: 22 additions & 0 deletions stdlib/lib2to3/fixes/fix_imports.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from _typeshed import StrPath
from collections.abc import Generator
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base
from ..pytree import Node

MAPPING: dict[str, str]

def alternates(members): ...
def build_pattern(mapping=...) -> Generator[str, None, None]: ...

class FixImports(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
mapping = MAPPING # noqa: F821
def build_pattern(self): ...
def compile_pattern(self) -> None: ...
def match(self, node): ...
replace: dict[str, str]
def start_tree(self, tree: Node, filename: StrPath) -> None: ...
def transform(self, node, results) -> None: ...
6 changes: 6 additions & 0 deletions stdlib/lib2to3/fixes/fix_imports2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import fix_imports

MAPPING: dict[str, str]

class FixImports2(fix_imports.FixImports):
mapping = MAPPING # noqa: F821
12 changes: 12 additions & 0 deletions stdlib/lib2to3/fixes/fix_input.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from _typeshed import Incomplete
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

context: Incomplete

class FixInput(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
10 changes: 10 additions & 0 deletions stdlib/lib2to3/fixes/fix_intern.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixIntern(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
order: ClassVar[Literal["pre"]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
9 changes: 9 additions & 0 deletions stdlib/lib2to3/fixes/fix_isinstance.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixIsinstance(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results) -> None: ...
10 changes: 10 additions & 0 deletions stdlib/lib2to3/fixes/fix_itertools.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixItertools(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
it_funcs: str
PATTERN: ClassVar[str]
def transform(self, node, results) -> None: ...
8 changes: 8 additions & 0 deletions stdlib/lib2to3/fixes/fix_itertools_imports.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lib2to3 import fixer_base
from typing import ClassVar
from typing_extensions import Literal

class FixItertoolsImports(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
def transform(self, node, results): ...
8 changes: 8 additions & 0 deletions stdlib/lib2to3/fixes/fix_long.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lib2to3 import fixer_base
from typing import ClassVar
from typing_extensions import Literal

class FixLong(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[Literal["'long'"]]
def transform(self, node, results) -> None: ...
10 changes: 10 additions & 0 deletions stdlib/lib2to3/fixes/fix_map.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import ClassVar
from typing_extensions import Literal

from .. import fixer_base

class FixMap(fixer_base.ConditionalFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[str]
skip_on: ClassVar[Literal["future_builtins.map"]]
def transform(self, node, results): ...
Loading