1 from collections.abc import Container, Generator, Iterable, Mapping
2 from logging import Logger
3 from typing import Any, ClassVar, NoReturn
5 from .pgen2.grammar import Grammar
7 _Driver = Any # really lib2to3.driver.Driver
8 _BottomMatcher = Any # really lib2to3.btm_matcher.BottomMatcher
10 def get_all_fix_names(fixer_pkg: str, remove_prefix: bool = ...) -> list[str]: ...
11 def get_fixers_from_package(pkg_name: str) -> list[str]: ...
13 class FixerError(Exception): ...
15 class RefactoringTool:
16 CLASS_PREFIX: ClassVar[str]
17 FILE_PREFIX: ClassVar[str]
19 explicit: Container[str]
20 options: dict[str, Any]
22 write_unchanged_files: bool
32 bmi_pre_order: list[Any]
33 bmi_post_order: list[Any]
35 self, fixer_names: Iterable[str], options: Mapping[str, Any] | None = ..., explicit: Container[str] | None = ...
37 def get_fixers(self) -> tuple[list[Any], list[Any]]: ...
38 def log_error(self, msg: str, *args: Any, **kwds: Any) -> NoReturn: ...
39 def log_message(self, msg: str, *args: Any) -> None: ...
40 def log_debug(self, msg: str, *args: Any) -> None: ...
41 def print_output(self, old_text: str, new_text: str, filename: str, equal): ...
42 def refactor(self, items: Iterable[str], write: bool = ..., doctests_only: bool = ...) -> None: ...
43 def refactor_dir(self, dir_name: str, write: bool = ..., doctests_only: bool = ...) -> None: ...
44 def _read_python_source(self, filename: str) -> tuple[str, str]: ...
45 def refactor_file(self, filename: str, write: bool = ..., doctests_only: bool = ...) -> None: ...
46 def refactor_string(self, data: str, name: str): ...
47 def refactor_stdin(self, doctests_only: bool = ...) -> None: ...
48 def refactor_tree(self, tree, name: str) -> bool: ...
49 def traverse_by(self, fixers, traversal) -> None: ...
51 self, new_text: str, filename: str, old_text: str | None = ..., write: bool = ..., encoding: str | None = ...
53 def write_file(self, new_text: str, filename: str, old_text: str, encoding: str | None = ...) -> None: ...
56 def refactor_docstring(self, input: str, filename: str) -> str: ...
57 def refactor_doctest(self, block: list[str], lineno: int, indent: int, filename: str) -> list[str]: ...
58 def summarize(self) -> None: ...
59 def parse_block(self, block: Iterable[str], lineno: int, indent: int): ...
61 self, block: Iterable[str], lineno: int, indent: int
62 ) -> Generator[tuple[Any, Any, tuple[int, int], tuple[int, int], str], None, None]: ...
63 def gen_lines(self, block: Iterable[str], indent: int) -> Generator[str, None, None]: ...
65 class MultiprocessingUnsupported(Exception): ...
67 class MultiprocessRefactoringTool(RefactoringTool):
69 output_lock: Any | None
70 def refactor(self, items: Iterable[str], write: bool = ..., doctests_only: bool = ..., num_processes: int = ...) -> None: ...