From bf36a1dbb58377cb08a4a995067c4ad26f916908 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 21 Feb 2023 01:24:42 -0500 Subject: [PATCH 1/6] Added fixers to lib2to3 --- out/lib2to3/__init__.pyi | 0 out/lib2to3/btm_matcher.pyi | 25 ++++ out/lib2to3/btm_utils.pyi | 30 +++++ out/lib2to3/fixer_base.pyi | 37 ++++++ out/lib2to3/fixer_util.pyi | 46 ++++++++ out/lib2to3/main.pyi | 15 +++ out/lib2to3/patcomp.pyi | 25 ++++ out/lib2to3/pgen2/__init__.pyi | 0 out/lib2to3/pgen2/conv.pyi | 16 +++ out/lib2to3/pgen2/driver.pyi | 14 +++ out/lib2to3/pgen2/grammar.pyi | 24 ++++ out/lib2to3/pgen2/literals.pyi | 7 ++ out/lib2to3/pgen2/parse.pyi | 24 ++++ out/lib2to3/pgen2/pgen.pyi | 45 +++++++ out/lib2to3/pgen2/token.pyi | 69 +++++++++++ out/lib2to3/pgen2/tokenize.pyi | 90 ++++++++++++++ out/lib2to3/pygram.pyi | 13 +++ out/lib2to3/pytree.pyi | 110 ++++++++++++++++++ out/lib2to3/refactor.pyi | 65 +++++++++++ pyrightconfig.stricter.json | 3 +- stdlib/lib2to3/btm_matcher.pyi | 30 +++++ stdlib/lib2to3/fixer_base.pyi | 41 +++++++ stdlib/lib2to3/fixes/__init__.pyi | 0 stdlib/lib2to3/fixes/fix_apply.pyi | 9 ++ stdlib/lib2to3/fixes/fix_asserts.pyi | 11 ++ stdlib/lib2to3/fixes/fix_basestring.pyi | 9 ++ stdlib/lib2to3/fixes/fix_buffer.pyi | 10 ++ stdlib/lib2to3/fixes/fix_dict.pyi | 17 +++ stdlib/lib2to3/fixes/fix_except.pyi | 15 +++ stdlib/lib2to3/fixes/fix_exec.pyi | 9 ++ stdlib/lib2to3/fixes/fix_execfile.pyi | 9 ++ stdlib/lib2to3/fixes/fix_exitfunc.pyi | 12 ++ stdlib/lib2to3/fixes/fix_filter.pyi | 10 ++ stdlib/lib2to3/fixes/fix_funcattrs.pyi | 9 ++ stdlib/lib2to3/fixes/fix_future.pyi | 9 ++ stdlib/lib2to3/fixes/fix_getcwdu.pyi | 9 ++ stdlib/lib2to3/fixes/fix_has_key.pyi | 9 ++ stdlib/lib2to3/fixes/fix_idioms.pyi | 17 +++ stdlib/lib2to3/fixes/fix_import.pyi | 15 +++ stdlib/lib2to3/fixes/fix_imports.pyi | 20 ++++ stdlib/lib2to3/fixes/fix_imports2.pyi | 6 + stdlib/lib2to3/fixes/fix_input.pyi | 12 ++ stdlib/lib2to3/fixes/fix_intern.pyi | 10 ++ stdlib/lib2to3/fixes/fix_isinstance.pyi | 9 ++ stdlib/lib2to3/fixes/fix_itertools.pyi | 10 ++ .../lib2to3/fixes/fix_itertools_imports.pyi | 8 ++ stdlib/lib2to3/fixes/fix_long.pyi | 8 ++ stdlib/lib2to3/fixes/fix_map.pyi | 10 ++ stdlib/lib2to3/fixes/fix_metaclass.pyi | 18 +++ stdlib/lib2to3/fixes/fix_methodattrs.pyi | 11 ++ stdlib/lib2to3/fixes/fix_ne.pyi | 9 ++ stdlib/lib2to3/fixes/fix_next.pyi | 18 +++ stdlib/lib2to3/fixes/fix_nonzero.pyi | 9 ++ stdlib/lib2to3/fixes/fix_numliterals.pyi | 9 ++ stdlib/lib2to3/fixes/fix_operator.pyi | 13 +++ stdlib/lib2to3/fixes/fix_paren.pyi | 9 ++ stdlib/lib2to3/fixes/fix_print.pyi | 13 +++ stdlib/lib2to3/fixes/fix_raise.pyi | 9 ++ stdlib/lib2to3/fixes/fix_raw_input.pyi | 9 ++ stdlib/lib2to3/fixes/fix_reduce.pyi | 9 ++ stdlib/lib2to3/fixes/fix_reload.pyi | 10 ++ stdlib/lib2to3/fixes/fix_renames.pyi | 18 +++ stdlib/lib2to3/fixes/fix_repr.pyi | 9 ++ stdlib/lib2to3/fixes/fix_set_literal.pyi | 9 ++ stdlib/lib2to3/fixes/fix_standarderror.pyi | 9 ++ stdlib/lib2to3/fixes/fix_sys_exc.pyi | 10 ++ stdlib/lib2to3/fixes/fix_throw.pyi | 9 ++ stdlib/lib2to3/fixes/fix_tuple_params.pyi | 18 +++ stdlib/lib2to3/fixes/fix_types.pyi | 9 ++ stdlib/lib2to3/fixes/fix_unicode.pyi | 11 ++ stdlib/lib2to3/fixes/fix_urllib.pyi | 14 +++ stdlib/lib2to3/fixes/fix_ws_comma.pyi | 14 +++ stdlib/lib2to3/fixes/fix_xrange.pyi | 20 ++++ stdlib/lib2to3/fixes/fix_xreadlines.pyi | 9 ++ stdlib/lib2to3/fixes/fix_zip.pyi | 10 ++ stdlib/lib2to3/main.pyi | 43 +++++++ stdlib/lib2to3/pgen2/driver.pyi | 6 +- stdlib/lib2to3/pgen2/parse.pyi | 4 +- stdlib/lib2to3/pgen2/pgen.pyi | 15 ++- stdlib/lib2to3/pytree.pyi | 58 ++++++--- stdlib/lib2to3/refactor.pyi | 82 +++++++------ 81 files changed, 1460 insertions(+), 64 deletions(-) create mode 100644 out/lib2to3/__init__.pyi create mode 100644 out/lib2to3/btm_matcher.pyi create mode 100644 out/lib2to3/btm_utils.pyi create mode 100644 out/lib2to3/fixer_base.pyi create mode 100644 out/lib2to3/fixer_util.pyi create mode 100644 out/lib2to3/main.pyi create mode 100644 out/lib2to3/patcomp.pyi create mode 100644 out/lib2to3/pgen2/__init__.pyi create mode 100644 out/lib2to3/pgen2/conv.pyi create mode 100644 out/lib2to3/pgen2/driver.pyi create mode 100644 out/lib2to3/pgen2/grammar.pyi create mode 100644 out/lib2to3/pgen2/literals.pyi create mode 100644 out/lib2to3/pgen2/parse.pyi create mode 100644 out/lib2to3/pgen2/pgen.pyi create mode 100644 out/lib2to3/pgen2/token.pyi create mode 100644 out/lib2to3/pgen2/tokenize.pyi create mode 100644 out/lib2to3/pygram.pyi create mode 100644 out/lib2to3/pytree.pyi create mode 100644 out/lib2to3/refactor.pyi create mode 100644 stdlib/lib2to3/btm_matcher.pyi create mode 100644 stdlib/lib2to3/fixer_base.pyi create mode 100644 stdlib/lib2to3/fixes/__init__.pyi create mode 100644 stdlib/lib2to3/fixes/fix_apply.pyi create mode 100644 stdlib/lib2to3/fixes/fix_asserts.pyi create mode 100644 stdlib/lib2to3/fixes/fix_basestring.pyi create mode 100644 stdlib/lib2to3/fixes/fix_buffer.pyi create mode 100644 stdlib/lib2to3/fixes/fix_dict.pyi create mode 100644 stdlib/lib2to3/fixes/fix_except.pyi create mode 100644 stdlib/lib2to3/fixes/fix_exec.pyi create mode 100644 stdlib/lib2to3/fixes/fix_execfile.pyi create mode 100644 stdlib/lib2to3/fixes/fix_exitfunc.pyi create mode 100644 stdlib/lib2to3/fixes/fix_filter.pyi create mode 100644 stdlib/lib2to3/fixes/fix_funcattrs.pyi create mode 100644 stdlib/lib2to3/fixes/fix_future.pyi create mode 100644 stdlib/lib2to3/fixes/fix_getcwdu.pyi create mode 100644 stdlib/lib2to3/fixes/fix_has_key.pyi create mode 100644 stdlib/lib2to3/fixes/fix_idioms.pyi create mode 100644 stdlib/lib2to3/fixes/fix_import.pyi create mode 100644 stdlib/lib2to3/fixes/fix_imports.pyi create mode 100644 stdlib/lib2to3/fixes/fix_imports2.pyi create mode 100644 stdlib/lib2to3/fixes/fix_input.pyi create mode 100644 stdlib/lib2to3/fixes/fix_intern.pyi create mode 100644 stdlib/lib2to3/fixes/fix_isinstance.pyi create mode 100644 stdlib/lib2to3/fixes/fix_itertools.pyi create mode 100644 stdlib/lib2to3/fixes/fix_itertools_imports.pyi create mode 100644 stdlib/lib2to3/fixes/fix_long.pyi create mode 100644 stdlib/lib2to3/fixes/fix_map.pyi create mode 100644 stdlib/lib2to3/fixes/fix_metaclass.pyi create mode 100644 stdlib/lib2to3/fixes/fix_methodattrs.pyi create mode 100644 stdlib/lib2to3/fixes/fix_ne.pyi create mode 100644 stdlib/lib2to3/fixes/fix_next.pyi create mode 100644 stdlib/lib2to3/fixes/fix_nonzero.pyi create mode 100644 stdlib/lib2to3/fixes/fix_numliterals.pyi create mode 100644 stdlib/lib2to3/fixes/fix_operator.pyi create mode 100644 stdlib/lib2to3/fixes/fix_paren.pyi create mode 100644 stdlib/lib2to3/fixes/fix_print.pyi create mode 100644 stdlib/lib2to3/fixes/fix_raise.pyi create mode 100644 stdlib/lib2to3/fixes/fix_raw_input.pyi create mode 100644 stdlib/lib2to3/fixes/fix_reduce.pyi create mode 100644 stdlib/lib2to3/fixes/fix_reload.pyi create mode 100644 stdlib/lib2to3/fixes/fix_renames.pyi create mode 100644 stdlib/lib2to3/fixes/fix_repr.pyi create mode 100644 stdlib/lib2to3/fixes/fix_set_literal.pyi create mode 100644 stdlib/lib2to3/fixes/fix_standarderror.pyi create mode 100644 stdlib/lib2to3/fixes/fix_sys_exc.pyi create mode 100644 stdlib/lib2to3/fixes/fix_throw.pyi create mode 100644 stdlib/lib2to3/fixes/fix_tuple_params.pyi create mode 100644 stdlib/lib2to3/fixes/fix_types.pyi create mode 100644 stdlib/lib2to3/fixes/fix_unicode.pyi create mode 100644 stdlib/lib2to3/fixes/fix_urllib.pyi create mode 100644 stdlib/lib2to3/fixes/fix_ws_comma.pyi create mode 100644 stdlib/lib2to3/fixes/fix_xrange.pyi create mode 100644 stdlib/lib2to3/fixes/fix_xreadlines.pyi create mode 100644 stdlib/lib2to3/fixes/fix_zip.pyi create mode 100644 stdlib/lib2to3/main.pyi diff --git a/out/lib2to3/__init__.pyi b/out/lib2to3/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/out/lib2to3/btm_matcher.pyi b/out/lib2to3/btm_matcher.pyi new file mode 100644 index 000000000000..bf6ea17f05f2 --- /dev/null +++ b/out/lib2to3/btm_matcher.pyi @@ -0,0 +1,25 @@ +from . import pytree as pytree +from .btm_utils import reduce_tree as reduce_tree +from _typeshed import Incomplete + +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) -> None: ... + def add(self, pattern, start): ... + def run(self, leaves): ... + def print_ac(self) -> None: ... + +def type_repr(type_num): ... diff --git a/out/lib2to3/btm_utils.pyi b/out/lib2to3/btm_utils.pyi new file mode 100644 index 000000000000..1c1ad8398f4a --- /dev/null +++ b/out/lib2to3/btm_utils.pyi @@ -0,0 +1,30 @@ +from . import pytree as pytree +from .pgen2 import grammar as grammar, token as token +from .pygram import pattern_symbols as pattern_symbols, python_symbols as python_symbols +from _typeshed import Incomplete +from collections.abc import Generator + +syms = pattern_symbols +pysyms = python_symbols +tokens: Incomplete +token_labels = token +TYPE_ANY: int +TYPE_ALTERNATIVES: int +TYPE_GROUP: int + +class MinNode: + type: Incomplete + name: Incomplete + children: Incomplete + leaf: bool + parent: Incomplete + alternatives: Incomplete + group: Incomplete + def __init__(self, type: Incomplete | None = ..., name: Incomplete | None = ...) -> None: ... + def leaf_to_root(self): ... + def get_linear_subpattern(self): ... + def leaves(self) -> Generator[Incomplete, None, None]: ... + +def reduce_tree(node, parent: Incomplete | None = ...): ... +def get_characteristic_subpattern(subpatterns): ... +def rec_test(sequence, test_func) -> Generator[Incomplete, None, None]: ... diff --git a/out/lib2to3/fixer_base.pyi b/out/lib2to3/fixer_base.pyi new file mode 100644 index 000000000000..00aa336cde4c --- /dev/null +++ b/out/lib2to3/fixer_base.pyi @@ -0,0 +1,37 @@ +from . import pygram as pygram +from .fixer_util import does_tree_import as does_tree_import +from .patcomp import PatternCompiler as PatternCompiler +from _typeshed import Incomplete + +class BaseFix: + PATTERN: Incomplete + pattern: Incomplete + pattern_tree: Incomplete + options: Incomplete + filename: Incomplete + numbers: Incomplete + used_names: Incomplete + order: str + explicit: bool + run_order: int + keep_line_order: bool + BM_compatible: bool + syms: Incomplete + log: Incomplete + def __init__(self, options, log) -> None: ... + def compile_pattern(self) -> None: ... + def set_filename(self, filename) -> None: ... + def match(self, node): ... + def transform(self, node, results) -> None: ... + def new_name(self, template: str = ...): ... + first_log: bool + def log_message(self, message) -> None: ... + def cannot_convert(self, node, reason: Incomplete | None = ...) -> None: ... + def warning(self, node, reason) -> None: ... + def start_tree(self, tree, filename) -> None: ... + def finish_tree(self, tree, filename) -> None: ... + +class ConditionalFix(BaseFix): + skip_on: Incomplete + def start_tree(self, *args) -> None: ... + def should_skip(self, node): ... diff --git a/out/lib2to3/fixer_util.pyi b/out/lib2to3/fixer_util.pyi new file mode 100644 index 000000000000..feb96daa74c7 --- /dev/null +++ b/out/lib2to3/fixer_util.pyi @@ -0,0 +1,46 @@ +from . import patcomp as patcomp +from .pgen2 import token as token +from .pytree import Leaf as Leaf, Node as Node +from _typeshed import Incomplete +from collections.abc import Generator + +def KeywordArg(keyword, value): ... +def LParen(): ... +def RParen(): ... +def Assign(target, source): ... +def Name(name, prefix: Incomplete | None = ...): ... +def Attr(obj, attr): ... +def Comma(): ... +def Dot(): ... +def ArgList(args, lparen=..., rparen=...): ... +def Call(func_name, args: Incomplete | None = ..., prefix: Incomplete | None = ...): ... +def Newline(): ... +def BlankLine(): ... +def Number(n, prefix: Incomplete | None = ...): ... +def Subscript(index_node): ... +def String(string, prefix: Incomplete | None = ...): ... +def ListComp(xp, fp, it, test: Incomplete | None = ...): ... +def FromImport(package_name, name_leafs): ... +def ImportAndCall(node, results, names): ... +def is_tuple(node): ... +def is_list(node): ... +def parenthesize(node): ... + +consuming_calls: Incomplete + +def attr_chain(obj, attr) -> Generator[Incomplete, None, None]: ... + +p0: str +p1: str +p2: str +pats_built: bool + +def in_special_context(node): ... +def is_probably_builtin(node): ... +def find_indentation(node): ... +def make_suite(node): ... +def find_root(node): ... +def does_tree_import(package, name, node): ... +def is_import(node): ... +def touch_import(package, name, node): ... +def find_binding(name, node, package: Incomplete | None = ...): ... diff --git a/out/lib2to3/main.pyi b/out/lib2to3/main.pyi new file mode 100644 index 000000000000..7168e899494d --- /dev/null +++ b/out/lib2to3/main.pyi @@ -0,0 +1,15 @@ +from . import refactor as refactor +from _typeshed import Incomplete + +def diff_texts(a, b, filename): ... + +class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool): + nobackups: Incomplete + show_diffs: Incomplete + def __init__(self, fixers, options, explicit, nobackups, show_diffs, input_base_dir: str = ..., output_dir: str = ..., append_suffix: str = ...) -> None: ... + def log_error(self, msg, *args, **kwargs) -> None: ... + def write_file(self, new_text, filename, old_text, encoding) -> None: ... + def print_output(self, old, new, filename, equal) -> None: ... + +def warn(msg) -> None: ... +def main(fixer_pkg, args: Incomplete | None = ...): ... diff --git a/out/lib2to3/patcomp.pyi b/out/lib2to3/patcomp.pyi new file mode 100644 index 000000000000..0221bcd60ce5 --- /dev/null +++ b/out/lib2to3/patcomp.pyi @@ -0,0 +1,25 @@ +from . import pygram as pygram, pytree as pytree +from .pgen2 import driver as driver, grammar as grammar, literals as literals, parse as parse, token as token, tokenize as tokenize +from _typeshed import Incomplete +from collections.abc import Generator + +class PatternSyntaxError(Exception): ... + +def tokenize_wrapper(input) -> Generator[Incomplete, None, None]: ... + +class PatternCompiler: + grammar: Incomplete + syms: Incomplete + pygrammar: Incomplete + pysyms: Incomplete + driver: Incomplete + def __init__(self, grammar_file: Incomplete | None = ...) -> None: ... + def compile_pattern(self, input, debug: bool = ..., with_tree: bool = ...): ... + def compile_node(self, node): ... + def compile_basic(self, nodes, repeat: Incomplete | None = ...): ... + def get_int(self, node): ... + +TOKEN_MAP: Incomplete + +def pattern_convert(grammar, raw_node_info): ... +def compile_pattern(pattern): ... diff --git a/out/lib2to3/pgen2/__init__.pyi b/out/lib2to3/pgen2/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/out/lib2to3/pgen2/conv.pyi b/out/lib2to3/pgen2/conv.pyi new file mode 100644 index 000000000000..5d0e28041368 --- /dev/null +++ b/out/lib2to3/pgen2/conv.pyi @@ -0,0 +1,16 @@ +from _typeshed import Incomplete +from pgen2 import grammar + +class Converter(grammar.Grammar): + def run(self, graminit_h, graminit_c) -> None: ... + symbol2number: Incomplete + number2symbol: Incomplete + def parse_graminit_h(self, filename): ... + states: Incomplete + dfas: Incomplete + labels: Incomplete + start: Incomplete + def parse_graminit_c(self, filename): ... + keywords: Incomplete + tokens: Incomplete + def finish_off(self) -> None: ... diff --git a/out/lib2to3/pgen2/driver.pyi b/out/lib2to3/pgen2/driver.pyi new file mode 100644 index 000000000000..3f0c456be49c --- /dev/null +++ b/out/lib2to3/pgen2/driver.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +class Driver: + grammar: Incomplete + logger: Incomplete + convert: Incomplete + def __init__(self, grammar, convert: Incomplete | None = ..., logger: Incomplete | None = ...) -> None: ... + def parse_tokens(self, tokens, debug: bool = ...): ... + def parse_stream_raw(self, stream, debug: bool = ...): ... + def parse_stream(self, stream, debug: bool = ...): ... + def parse_file(self, filename, encoding: Incomplete | None = ..., debug: bool = ...): ... + def parse_string(self, text, debug: bool = ...): ... + +def load_grammar(gt: str = ..., gp: Incomplete | None = ..., save: bool = ..., force: bool = ..., logger: Incomplete | None = ...): ... diff --git a/out/lib2to3/pgen2/grammar.pyi b/out/lib2to3/pgen2/grammar.pyi new file mode 100644 index 000000000000..751b86dd586e --- /dev/null +++ b/out/lib2to3/pgen2/grammar.pyi @@ -0,0 +1,24 @@ +from . import token as token +from _typeshed import Incomplete + +class Grammar: + symbol2number: Incomplete + number2symbol: Incomplete + states: Incomplete + dfas: Incomplete + labels: Incomplete + keywords: Incomplete + tokens: Incomplete + symbol2label: Incomplete + start: int + def __init__(self) -> None: ... + def dump(self, filename) -> None: ... + def load(self, filename) -> None: ... + def loads(self, pkl) -> None: ... + def copy(self): ... + def report(self) -> None: ... + +opmap_raw: str +opmap: Incomplete +op: Incomplete +name: Incomplete diff --git a/out/lib2to3/pgen2/literals.pyi b/out/lib2to3/pgen2/literals.pyi new file mode 100644 index 000000000000..1a53c10d890e --- /dev/null +++ b/out/lib2to3/pgen2/literals.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +simple_escapes: Incomplete + +def escape(m): ... +def evalString(s): ... +def test() -> None: ... diff --git a/out/lib2to3/pgen2/parse.pyi b/out/lib2to3/pgen2/parse.pyi new file mode 100644 index 000000000000..ccedec07cbe4 --- /dev/null +++ b/out/lib2to3/pgen2/parse.pyi @@ -0,0 +1,24 @@ +from . import token as token +from _typeshed import Incomplete + +class ParseError(Exception): + msg: Incomplete + type: Incomplete + value: Incomplete + context: Incomplete + def __init__(self, msg, type, value, context) -> None: ... + def __reduce__(self): ... + +class Parser: + grammar: Incomplete + convert: Incomplete + def __init__(self, grammar, convert: Incomplete | None = ...) -> None: ... + stack: Incomplete + rootnode: Incomplete + used_names: Incomplete + def setup(self, start: Incomplete | None = ...) -> None: ... + def addtoken(self, type, value, context): ... + def classify(self, type, value, context): ... + def shift(self, type, value, newstate, context) -> None: ... + def push(self, type, newdfa, newstate, context) -> None: ... + def pop(self) -> None: ... diff --git a/out/lib2to3/pgen2/pgen.pyi b/out/lib2to3/pgen2/pgen.pyi new file mode 100644 index 000000000000..5556fff301db --- /dev/null +++ b/out/lib2to3/pgen2/pgen.pyi @@ -0,0 +1,45 @@ +from . import grammar as grammar, token as token, tokenize as tokenize +from _typeshed import Incomplete + +class PgenGrammar(grammar.Grammar): ... + +class ParserGenerator: + filename: Incomplete + stream: Incomplete + generator: Incomplete + first: Incomplete + def __init__(self, filename, stream: Incomplete | None = ...) -> None: ... + def make_grammar(self): ... + def make_first(self, c, name): ... + def make_label(self, c, label): ... + def addfirstsets(self) -> None: ... + def calcfirst(self, name) -> None: ... + def parse(self): ... + def make_dfa(self, start, finish): ... + def dump_nfa(self, name, start, finish) -> None: ... + def dump_dfa(self, name, dfa) -> None: ... + def simplify_dfa(self, dfa) -> None: ... + def parse_rhs(self): ... + def parse_alt(self): ... + def parse_item(self): ... + def parse_atom(self): ... + def expect(self, type, value: Incomplete | None = ...): ... + def gettoken(self) -> None: ... + def raise_error(self, msg, *args) -> None: ... + +class NFAState: + arcs: Incomplete + def __init__(self) -> None: ... + def addarc(self, next, label: Incomplete | None = ...) -> None: ... + +class DFAState: + nfaset: Incomplete + isfinal: Incomplete + arcs: Incomplete + def __init__(self, nfaset, final) -> None: ... + def addarc(self, next, label) -> None: ... + def unifystate(self, old, new) -> None: ... + def __eq__(self, other): ... + __hash__: Incomplete + +def generate_grammar(filename: str = ...): ... diff --git a/out/lib2to3/pgen2/token.pyi b/out/lib2to3/pgen2/token.pyi new file mode 100644 index 000000000000..c4308fdc533d --- /dev/null +++ b/out/lib2to3/pgen2/token.pyi @@ -0,0 +1,69 @@ +from _typeshed import Incomplete + +ENDMARKER: int +NAME: int +NUMBER: int +STRING: int +NEWLINE: int +INDENT: int +DEDENT: int +LPAR: int +RPAR: int +LSQB: int +RSQB: int +COLON: int +COMMA: int +SEMI: int +PLUS: int +MINUS: int +STAR: int +SLASH: int +VBAR: int +AMPER: int +LESS: int +GREATER: int +EQUAL: int +DOT: int +PERCENT: int +BACKQUOTE: int +LBRACE: int +RBRACE: int +EQEQUAL: int +NOTEQUAL: int +LESSEQUAL: int +GREATEREQUAL: int +TILDE: int +CIRCUMFLEX: int +LEFTSHIFT: int +RIGHTSHIFT: int +DOUBLESTAR: int +PLUSEQUAL: int +MINEQUAL: int +STAREQUAL: int +SLASHEQUAL: int +PERCENTEQUAL: int +AMPEREQUAL: int +VBAREQUAL: int +CIRCUMFLEXEQUAL: int +LEFTSHIFTEQUAL: int +RIGHTSHIFTEQUAL: int +DOUBLESTAREQUAL: int +DOUBLESLASH: int +DOUBLESLASHEQUAL: int +AT: int +ATEQUAL: int +OP: int +COMMENT: int +NL: int +RARROW: int +AWAIT: int +ASYNC: int +ERRORTOKEN: int +COLONEQUAL: int +N_TOKENS: int +NT_OFFSET: int +tok_name: Incomplete + +def ISTERMINAL(x): ... +def ISNONTERMINAL(x): ... +def ISEOF(x): ... diff --git a/out/lib2to3/pgen2/tokenize.pyi b/out/lib2to3/pgen2/tokenize.pyi new file mode 100644 index 000000000000..eea1852a1912 --- /dev/null +++ b/out/lib2to3/pgen2/tokenize.pyi @@ -0,0 +1,90 @@ +from lib2to3.pgen2.token import * +from _typeshed import Incomplete +from collections.abc import Generator + +bytes = str + +class TokenError(Exception): ... +class StopTokenizing(Exception): ... + +def tokenize(readline, tokeneater=...) -> None: ... + +class Untokenizer: + tokens: Incomplete + prev_row: int + prev_col: int + def __init__(self) -> None: ... + def add_whitespace(self, start) -> None: ... + def untokenize(self, iterable): ... + def compat(self, token, iterable) -> None: ... + +def untokenize(iterable): ... +def generate_tokens(readline) -> Generator[Incomplete, None, None]: ... + +# Names in __all__ with no definition: +# AMPER +# AMPEREQUAL +# ASYNC +# AT +# ATEQUAL +# AWAIT +# BACKQUOTE +# CIRCUMFLEX +# CIRCUMFLEXEQUAL +# COLON +# COLONEQUAL +# COMMA +# COMMENT +# DEDENT +# DOT +# DOUBLESLASH +# DOUBLESLASHEQUAL +# DOUBLESTAR +# DOUBLESTAREQUAL +# ENDMARKER +# EQEQUAL +# EQUAL +# ERRORTOKEN +# GREATER +# GREATEREQUAL +# INDENT +# ISEOF +# ISNONTERMINAL +# ISTERMINAL +# LBRACE +# LEFTSHIFT +# LEFTSHIFTEQUAL +# LESS +# LESSEQUAL +# LPAR +# LSQB +# MINEQUAL +# MINUS +# NAME +# NEWLINE +# NL +# NOTEQUAL +# NT_OFFSET +# NUMBER +# N_TOKENS +# OP +# PERCENT +# PERCENTEQUAL +# PLUS +# PLUSEQUAL +# RARROW +# RBRACE +# RIGHTSHIFT +# RIGHTSHIFTEQUAL +# RPAR +# RSQB +# SEMI +# SLASH +# SLASHEQUAL +# STAR +# STAREQUAL +# STRING +# TILDE +# VBAR +# VBAREQUAL +# tok_name diff --git a/out/lib2to3/pygram.pyi b/out/lib2to3/pygram.pyi new file mode 100644 index 000000000000..3702caa59ee1 --- /dev/null +++ b/out/lib2to3/pygram.pyi @@ -0,0 +1,13 @@ +from . import pytree as pytree +from .pgen2 import driver as driver, token as token +from _typeshed import Incomplete + +class Symbols: + def __init__(self, grammar) -> None: ... + +python_grammar: Incomplete +python_symbols: Incomplete +python_grammar_no_print_statement: Incomplete +python_grammar_no_print_and_exec_statement: Incomplete +pattern_grammar: Incomplete +pattern_symbols: Incomplete diff --git a/out/lib2to3/pytree.pyi b/out/lib2to3/pytree.pyi new file mode 100644 index 000000000000..3cb1382f5350 --- /dev/null +++ b/out/lib2to3/pytree.pyi @@ -0,0 +1,110 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +HUGE: int + +def type_repr(type_num): ... + +class Base: + type: Incomplete + parent: Incomplete + children: Incomplete + was_changed: bool + was_checked: bool + def __new__(cls, *args, **kwds): ... + def __eq__(self, other): ... + __hash__: Incomplete + def clone(self) -> None: ... + def post_order(self) -> None: ... + def pre_order(self) -> None: ... + def replace(self, new) -> None: ... + def get_lineno(self): ... + def changed(self) -> None: ... + def remove(self): ... + @property + def next_sibling(self): ... + @property + def prev_sibling(self): ... + def leaves(self) -> None: ... + def depth(self): ... + def get_suffix(self): ... + +class Node(Base): + type: Incomplete + children: Incomplete + fixers_applied: Incomplete + def __init__(self, type, children, context: Incomplete | None = ..., prefix: Incomplete | None = ..., fixers_applied: Incomplete | None = ...) -> None: ... + def __unicode__(self): ... + def clone(self): ... + def post_order(self) -> Generator[Incomplete, None, None]: ... + def pre_order(self) -> Generator[Incomplete, None, None]: ... + @property + def prefix(self): ... + @prefix.setter + def prefix(self, prefix) -> None: ... + def set_child(self, i, child) -> None: ... + def insert_child(self, i, child) -> None: ... + def append_child(self, child) -> None: ... + +class Leaf(Base): + lineno: int + column: int + type: Incomplete + value: Incomplete + fixers_applied: Incomplete + def __init__(self, type, value, context: Incomplete | None = ..., prefix: Incomplete | None = ..., fixers_applied=...) -> None: ... + def __unicode__(self): ... + def clone(self): ... + def leaves(self) -> Generator[Incomplete, None, None]: ... + def post_order(self) -> Generator[Incomplete, None, None]: ... + def pre_order(self) -> Generator[Incomplete, None, None]: ... + @property + def prefix(self): ... + @prefix.setter + def prefix(self, prefix) -> None: ... + +def convert(gr, raw_node): ... + +class BasePattern: + type: Incomplete + content: Incomplete + name: Incomplete + def __new__(cls, *args, **kwds): ... + def optimize(self): ... + def match(self, node, results: Incomplete | None = ...): ... + def match_seq(self, nodes, results: Incomplete | None = ...): ... + def generate_matches(self, nodes) -> Generator[Incomplete, None, None]: ... + +class LeafPattern(BasePattern): + type: Incomplete + content: Incomplete + name: Incomplete + def __init__(self, type: Incomplete | None = ..., content: Incomplete | None = ..., name: Incomplete | None = ...) -> None: ... + def match(self, node, results: Incomplete | None = ...): ... + +class NodePattern(BasePattern): + wildcards: bool + type: Incomplete + content: Incomplete + name: Incomplete + def __init__(self, type: Incomplete | None = ..., content: Incomplete | None = ..., name: Incomplete | None = ...) -> None: ... + +class WildcardPattern(BasePattern): + content: Incomplete + min: Incomplete + max: Incomplete + name: Incomplete + def __init__(self, content: Incomplete | None = ..., min: int = ..., max=..., name: Incomplete | None = ...) -> None: ... + def optimize(self): ... + def match(self, node, results: Incomplete | None = ...): ... + def match_seq(self, nodes, results: Incomplete | None = ...): ... + def generate_matches(self, nodes) -> Generator[Incomplete, None, None]: ... + +class NegatedPattern(BasePattern): + content: Incomplete + def __init__(self, content: Incomplete | None = ...) -> None: ... + def match(self, node): ... + def match_seq(self, nodes): ... + def generate_matches(self, nodes) -> Generator[Incomplete, None, None]: ... + +def generate_matches(patterns, nodes) -> Generator[Incomplete, None, None]: ... diff --git a/out/lib2to3/refactor.pyi b/out/lib2to3/refactor.pyi new file mode 100644 index 000000000000..959a6fd07ef6 --- /dev/null +++ b/out/lib2to3/refactor.pyi @@ -0,0 +1,65 @@ +from . import pygram as pygram, pytree as pytree +from .fixer_util import find_root as find_root +from .pgen2 import driver as driver, token as token, tokenize as tokenize +from _typeshed import Incomplete +from collections.abc import Generator, Iterable as Iterable + +def get_all_fix_names(fixer_pkg, remove_prefix: bool = ...): ... + +class _EveryNode(Exception): ... + +def get_fixers_from_package(pkg_name): ... + +class FixerError(Exception): ... + +class RefactoringTool: + CLASS_PREFIX: str + FILE_PREFIX: str + fixers: Incomplete + explicit: Incomplete + options: Incomplete + grammar: Incomplete + write_unchanged_files: Incomplete + errors: Incomplete + logger: Incomplete + fixer_log: Incomplete + wrote: bool + driver: Incomplete + files: Incomplete + BM: Incomplete + bmi_pre_order: Incomplete + bmi_post_order: Incomplete + bmi_pre_order_heads: Incomplete + bmi_post_order_heads: Incomplete + def __init__(self, fixer_names, options: Incomplete | None = ..., explicit: Incomplete | None = ...) -> None: ... + def get_fixers(self): ... + def log_error(self, msg, *args, **kwds) -> None: ... + def log_message(self, msg, *args) -> None: ... + def log_debug(self, msg, *args) -> None: ... + def print_output(self, old_text, new_text, filename, equal) -> None: ... + def refactor(self, items, write: bool = ..., doctests_only: bool = ...) -> None: ... + def refactor_dir(self, dir_name, write: bool = ..., doctests_only: bool = ...) -> None: ... + def refactor_file(self, filename, write: bool = ..., doctests_only: bool = ...) -> None: ... + def refactor_string(self, data, name): ... + def refactor_stdin(self, doctests_only: bool = ...) -> None: ... + def refactor_tree(self, tree, name): ... + def traverse_by(self, fixers, traversal) -> None: ... + def processed_file(self, new_text, filename, old_text: Incomplete | None = ..., write: bool = ..., encoding: Incomplete | None = ...) -> None: ... + def write_file(self, new_text, filename, old_text, encoding: Incomplete | None = ...) -> None: ... + PS1: str + PS2: str + def refactor_docstring(self, input, filename): ... + def refactor_doctest(self, block, lineno, indent, filename): ... + def summarize(self) -> None: ... + def parse_block(self, block, lineno, indent): ... + def wrap_toks(self, block, lineno, indent) -> Generator[Incomplete, None, None]: ... + def gen_lines(self, block, indent) -> Generator[Incomplete, None, None]: ... + +class MultiprocessingUnsupported(Exception): ... + +class MultiprocessRefactoringTool(RefactoringTool): + queue: Incomplete + output_lock: Incomplete + def __init__(self, *args, **kwargs) -> None: ... + def refactor(self, items, write: bool = ..., doctests_only: bool = ..., num_processes: int = ...): ... + def refactor_file(self, *args, **kwargs): ... diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 80f5e6f6248a..3546b75d9c8e 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -9,7 +9,8 @@ // test cases use a custom pyrightconfig file "stubs/**/@tests/test_cases", "stdlib/distutils/command", - "stdlib/lib2to3/refactor.pyi", + "stdlib/lib2to3/fixer_base.pyi", + "stdlib/lib2to3/fixes/*.pyi", "stdlib/_tkinter.pyi", "stdlib/tkinter/__init__.pyi", "stdlib/tkinter/filedialog.pyi", diff --git a/stdlib/lib2to3/btm_matcher.pyi b/stdlib/lib2to3/btm_matcher.pyi new file mode 100644 index 000000000000..9b320ef1ed37 --- /dev/null +++ b/stdlib/lib2to3/btm_matcher.pyi @@ -0,0 +1,30 @@ +from _typeshed import Incomplete, SupportsGetItem +from collections import defaultdict +from collections.abc import Iterable +from lib2to3.fixer_base import BaseFix +from lib2to3.pytree import Leaf, Node +from typing import TypeVar + +_T = TypeVar("_T") + +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: _T) -> _T: ... diff --git a/stdlib/lib2to3/fixer_base.pyi b/stdlib/lib2to3/fixer_base.pyi new file mode 100644 index 000000000000..c045d096ed34 --- /dev/null +++ b/stdlib/lib2to3/fixer_base.pyi @@ -0,0 +1,41 @@ +from _typeshed import Incomplete +from abc import ABCMeta, abstractmethod +from typing import ClassVar, TypeVar +from typing_extensions import Literal, LiteralString + +from .pytree import Base, Leaf, Node + +_N = TypeVar("_N", bound=Base) + +class BaseFix: + PATTERN: ClassVar[LiteralString | None] + pattern_tree: Incomplete | None + options: Incomplete | None + filename: Incomplete | None + numbers: Incomplete + used_names: Incomplete + order: ClassVar[Literal["post", "pre"]] + explicit: bool + run_order: ClassVar[int] + keep_line_order: ClassVar[bool] + BM_compatible: ClassVar[bool] + syms: Incomplete + log: Incomplete + def __init__(self, options, log) -> None: ... + def compile_pattern(self) -> None: ... + def set_filename(self, filename) -> 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) -> None: ... + def cannot_convert(self, node: Base, reason: Incomplete | None = None) -> None: ... + def warning(self, node: Base, reason) -> None: ... + def start_tree(self, tree, filename) -> None: ... + def finish_tree(self, tree, filename) -> None: ... + +class ConditionalFix(BaseFix, metaclass=ABCMeta): + skip_on: ClassVar[LiteralString | None] + def start_tree(self, *args) -> None: ... + def should_skip(self, node: Base) -> bool: ... diff --git a/stdlib/lib2to3/fixes/__init__.pyi b/stdlib/lib2to3/fixes/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stdlib/lib2to3/fixes/fix_apply.pyi b/stdlib/lib2to3/fixes/fix_apply.pyi new file mode 100644 index 000000000000..d7255d9def43 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_apply.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixApply(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_asserts.pyi b/stdlib/lib2to3/fixes/fix_asserts.pyi new file mode 100644 index 000000000000..6f982e6d7946 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_asserts.pyi @@ -0,0 +1,11 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from ..fixer_base import BaseFix + +NAMES: dict[str, str] + +class FixAsserts(BaseFix): + BM_compatible: ClassVar[Literal[False]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_basestring.pyi b/stdlib/lib2to3/fixes/fix_basestring.pyi new file mode 100644 index 000000000000..84a354d32777 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_basestring.pyi @@ -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): ... diff --git a/stdlib/lib2to3/fixes/fix_buffer.pyi b/stdlib/lib2to3/fixes/fix_buffer.pyi new file mode 100644 index 000000000000..b601e9cabfc3 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_buffer.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixBuffer(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + explicit: bool + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_dict.pyi b/stdlib/lib2to3/fixes/fix_dict.pyi new file mode 100644 index 000000000000..a95cef107684 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_dict.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +iter_exempt: set[str] + +class FixDict(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... + P1: ClassVar[LiteralString] + p1: ClassVar[Incomplete] + P2: ClassVar[LiteralString] + p2: ClassVar[Incomplete] + def in_special_context(self, node, isiter): ... diff --git a/stdlib/lib2to3/fixes/fix_except.pyi b/stdlib/lib2to3/fixes/fix_except.pyi new file mode 100644 index 000000000000..efd925d6e9f1 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_except.pyi @@ -0,0 +1,15 @@ +from collections.abc import Generator, Iterable +from lib2to3.pytree import Base +from typing import ClassVar, TypeVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_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[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_exec.pyi b/stdlib/lib2to3/fixes/fix_exec.pyi new file mode 100644 index 000000000000..2c3c2fabda9c --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_exec.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixExec(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_execfile.pyi b/stdlib/lib2to3/fixes/fix_execfile.pyi new file mode 100644 index 000000000000..e90f001714cb --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_execfile.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixExecfile(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_exitfunc.pyi b/stdlib/lib2to3/fixes/fix_exitfunc.pyi new file mode 100644 index 000000000000..6746aa057b35 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_exitfunc.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete +from lib2to3 import fixer_base +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +class FixExitfunc(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def __init__(self, *args) -> None: ... + sys_import: Incomplete | None + def start_tree(self, tree, filename) -> None: ... + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_filter.pyi b/stdlib/lib2to3/fixes/fix_filter.pyi new file mode 100644 index 000000000000..18357f808837 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_filter.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixFilter(fixer_base.ConditionalFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + skip_on: ClassVar[Literal["future_builtins.filter"]] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_funcattrs.pyi b/stdlib/lib2to3/fixes/fix_funcattrs.pyi new file mode 100644 index 000000000000..13e63c80c394 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_funcattrs.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixFuncattrs(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_future.pyi b/stdlib/lib2to3/fixes/fix_future.pyi new file mode 100644 index 000000000000..fa83e61bbb6d --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_future.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixFuture(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_getcwdu.pyi b/stdlib/lib2to3/fixes/fix_getcwdu.pyi new file mode 100644 index 000000000000..4c2e45cb7fa6 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_getcwdu.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixGetcwdu(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_has_key.pyi b/stdlib/lib2to3/fixes/fix_has_key.pyi new file mode 100644 index 000000000000..b2d76e270829 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_has_key.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixHasKey(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_idioms.pyi b/stdlib/lib2to3/fixes/fix_idioms.pyi new file mode 100644 index 000000000000..e0ad60d555c1 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_idioms.pyi @@ -0,0 +1,17 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +CMP: str +TYPE: str + +class FixIdioms(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[False]] + explicit: bool + PATTERN: ClassVar[LiteralString] + 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: ... diff --git a/stdlib/lib2to3/fixes/fix_import.pyi b/stdlib/lib2to3/fixes/fix_import.pyi new file mode 100644 index 000000000000..b57f4c8d7442 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_import.pyi @@ -0,0 +1,15 @@ +from collections.abc import Generator +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +def traverse_imports(names) -> Generator[str, None, None]: ... + +class FixImport(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + skip: bool + def start_tree(self, tree, name) -> None: ... + def transform(self, node, results): ... + def probably_a_local_import(self, imp_name): ... diff --git a/stdlib/lib2to3/fixes/fix_imports.pyi b/stdlib/lib2to3/fixes/fix_imports.pyi new file mode 100644 index 000000000000..c36d68d21cd7 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_imports.pyi @@ -0,0 +1,20 @@ +from collections.abc import Generator +from typing import ClassVar +from typing_extensions import Literal + +from .. import fixer_base + +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, filename) -> None: ... + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_imports2.pyi b/stdlib/lib2to3/fixes/fix_imports2.pyi new file mode 100644 index 000000000000..e553dc7d832c --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_imports2.pyi @@ -0,0 +1,6 @@ +from . import fix_imports + +MAPPING: dict[str, str] + +class FixImports2(fix_imports.FixImports): + mapping = MAPPING # noqa: F821 diff --git a/stdlib/lib2to3/fixes/fix_input.pyi b/stdlib/lib2to3/fixes/fix_input.pyi new file mode 100644 index 000000000000..d6ad6ce49340 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_input.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +context: Incomplete + +class FixInput(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_intern.pyi b/stdlib/lib2to3/fixes/fix_intern.pyi new file mode 100644 index 000000000000..b15b9f5c70db --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_intern.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixIntern(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + order: ClassVar[Literal["pre"]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_isinstance.pyi b/stdlib/lib2to3/fixes/fix_isinstance.pyi new file mode 100644 index 000000000000..2cea351b76ce --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_isinstance.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixIsinstance(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_itertools.pyi b/stdlib/lib2to3/fixes/fix_itertools.pyi new file mode 100644 index 000000000000..3ef79eaf9ca5 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_itertools.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixItertools(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + it_funcs: str + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_itertools_imports.pyi b/stdlib/lib2to3/fixes/fix_itertools_imports.pyi new file mode 100644 index 000000000000..22d579e111cf --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_itertools_imports.pyi @@ -0,0 +1,8 @@ +from lib2to3 import fixer_base +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +class FixItertoolsImports(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_long.pyi b/stdlib/lib2to3/fixes/fix_long.pyi new file mode 100644 index 000000000000..c47f4528de47 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_long.pyi @@ -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: ... diff --git a/stdlib/lib2to3/fixes/fix_map.pyi b/stdlib/lib2to3/fixes/fix_map.pyi new file mode 100644 index 000000000000..b476f1277900 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_map.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixMap(fixer_base.ConditionalFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + skip_on: ClassVar[Literal["future_builtins.map"]] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_metaclass.pyi b/stdlib/lib2to3/fixes/fix_metaclass.pyi new file mode 100644 index 000000000000..cf2ceb5123c6 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_metaclass.pyi @@ -0,0 +1,18 @@ +from collections.abc import Generator +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base +from ..pytree import Base + +def has_metaclass(parent): ... +def fixup_parse_tree(cls_node) -> None: ... +def fixup_simple_stmt(parent, i, stmt_node) -> None: ... +def remove_trailing_newline(node) -> None: ... +def find_metas(cls_node) -> Generator[tuple[Base, int, Base], None, None]: ... +def fixup_indent(suite) -> None: ... + +class FixMetaclass(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_methodattrs.pyi b/stdlib/lib2to3/fixes/fix_methodattrs.pyi new file mode 100644 index 000000000000..e3a57f97f08e --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_methodattrs.pyi @@ -0,0 +1,11 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +MAP: dict[str, str] + +class FixMethodattrs(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_ne.pyi b/stdlib/lib2to3/fixes/fix_ne.pyi new file mode 100644 index 000000000000..95dfacccf219 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_ne.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal + +from .. import fixer_base + +class FixNe(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[False]] + def match(self, node): ... + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_next.pyi b/stdlib/lib2to3/fixes/fix_next.pyi new file mode 100644 index 000000000000..88eb664ae38e --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_next.pyi @@ -0,0 +1,18 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +bind_warning: str + +class FixNext(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + order: ClassVar[Literal["pre"]] + shadowed_next: bool + def start_tree(self, tree, filename) -> None: ... + def transform(self, node, results) -> None: ... + +def is_assign_target(node): ... +def find_assign(node): ... +def is_subtree(root, node): ... diff --git a/stdlib/lib2to3/fixes/fix_nonzero.pyi b/stdlib/lib2to3/fixes/fix_nonzero.pyi new file mode 100644 index 000000000000..55e3d09b9854 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_nonzero.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixNonzero(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_numliterals.pyi b/stdlib/lib2to3/fixes/fix_numliterals.pyi new file mode 100644 index 000000000000..6842e42e45f0 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_numliterals.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal + +from .. import fixer_base + +class FixNumliterals(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[False]] + def match(self, node): ... + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_operator.pyi b/stdlib/lib2to3/fixes/fix_operator.pyi new file mode 100644 index 000000000000..9607cdc488ba --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_operator.pyi @@ -0,0 +1,13 @@ +from lib2to3 import fixer_base +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +def invocation(s): ... + +class FixOperator(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + order: ClassVar[Literal["pre"]] + methods: str + obj: str + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_paren.pyi b/stdlib/lib2to3/fixes/fix_paren.pyi new file mode 100644 index 000000000000..ae99e1334ccf --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_paren.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixParen(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_print.pyi b/stdlib/lib2to3/fixes/fix_print.pyi new file mode 100644 index 000000000000..3d53f4572e67 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_print.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +parend_expr: Incomplete + +class FixPrint(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... + def add_kwarg(self, l_nodes, s_kwd, n_expr) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_raise.pyi b/stdlib/lib2to3/fixes/fix_raise.pyi new file mode 100644 index 000000000000..4961110cbf57 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_raise.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixRaise(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_raw_input.pyi b/stdlib/lib2to3/fixes/fix_raw_input.pyi new file mode 100644 index 000000000000..29184edb694f --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_raw_input.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixRawInput(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_reduce.pyi b/stdlib/lib2to3/fixes/fix_reduce.pyi new file mode 100644 index 000000000000..e974da7c62e9 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_reduce.pyi @@ -0,0 +1,9 @@ +from lib2to3 import fixer_base +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +class FixReduce(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + order: ClassVar[Literal["pre"]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_reload.pyi b/stdlib/lib2to3/fixes/fix_reload.pyi new file mode 100644 index 000000000000..c9aa5b5cbfd7 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_reload.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixReload(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + order: ClassVar[Literal["pre"]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_renames.pyi b/stdlib/lib2to3/fixes/fix_renames.pyi new file mode 100644 index 000000000000..37c3706b7299 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_renames.pyi @@ -0,0 +1,18 @@ +from collections.abc import Generator +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +MAPPING: dict[str, dict[str, str]] +LOOKUP: dict[tuple[str, str], str] + +def alternates(members): ... +def build_pattern() -> Generator[str, None, None]: ... + +class FixRenames(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + order: ClassVar[Literal["pre"]] + PATTERN: ClassVar[LiteralString] + def match(self, node): ... + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_repr.pyi b/stdlib/lib2to3/fixes/fix_repr.pyi new file mode 100644 index 000000000000..6e03fc01f65b --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_repr.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixRepr(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_set_literal.pyi b/stdlib/lib2to3/fixes/fix_set_literal.pyi new file mode 100644 index 000000000000..b1f1e86b95a4 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_set_literal.pyi @@ -0,0 +1,9 @@ +from lib2to3 import fixer_base +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +class FixSetLiteral(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + explicit: bool + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_standarderror.pyi b/stdlib/lib2to3/fixes/fix_standarderror.pyi new file mode 100644 index 000000000000..5f81b4fc78f4 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_standarderror.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixStandarderror(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_sys_exc.pyi b/stdlib/lib2to3/fixes/fix_sys_exc.pyi new file mode 100644 index 000000000000..807ee1f1a204 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_sys_exc.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixSysExc(fixer_base.BaseFix): + exc_info: ClassVar[list[str]] + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_throw.pyi b/stdlib/lib2to3/fixes/fix_throw.pyi new file mode 100644 index 000000000000..a20d5c21a25b --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_throw.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixThrow(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_tuple_params.pyi b/stdlib/lib2to3/fixes/fix_tuple_params.pyi new file mode 100644 index 000000000000..33883f82f504 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_tuple_params.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +def is_docstring(stmt): ... + +class FixTupleParams(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... + def transform_lambda(self, node, results) -> None: ... + +def simplify_args(node): ... +def find_params(node): ... +def map_to_index(param_list, prefix=..., d: Incomplete | None = ...): ... +def tuple_name(param_list): ... diff --git a/stdlib/lib2to3/fixes/fix_types.pyi b/stdlib/lib2to3/fixes/fix_types.pyi new file mode 100644 index 000000000000..0744ac42a20d --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_types.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixTypes(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_unicode.pyi b/stdlib/lib2to3/fixes/fix_unicode.pyi new file mode 100644 index 000000000000..2ae935cb9881 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_unicode.pyi @@ -0,0 +1,11 @@ +from typing import ClassVar +from typing_extensions import Literal + +from .. import fixer_base + +class FixUnicode(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[Literal["STRING | 'unicode' | 'unichr'"]] # type: ignore[name-defined] # Name "STRING" is not defined + unicode_literals: bool + def start_tree(self, tree, filename) -> None: ... + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_urllib.pyi b/stdlib/lib2to3/fixes/fix_urllib.pyi new file mode 100644 index 000000000000..24b38213c01f --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_urllib.pyi @@ -0,0 +1,14 @@ +from collections.abc import Generator +from lib2to3.fixes.fix_imports import FixImports +from typing_extensions import Literal + +MAPPING: dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]] + +def build_pattern() -> Generator[str, None, None]: ... + +class FixUrllib(FixImports): + def build_pattern(self): ... + def transform_import(self, node, results) -> None: ... + def transform_member(self, node, results): ... + def transform_dot(self, node, results) -> None: ... + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_ws_comma.pyi b/stdlib/lib2to3/fixes/fix_ws_comma.pyi new file mode 100644 index 000000000000..2e60d1656350 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_ws_comma.pyi @@ -0,0 +1,14 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base +from ..pytree import Leaf + +class FixWsComma(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[False]] + explicit: bool + PATTERN: ClassVar[LiteralString] + COMMA: Leaf + COLON: Leaf + SEPS: tuple[Leaf, Leaf] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_xrange.pyi b/stdlib/lib2to3/fixes/fix_xrange.pyi new file mode 100644 index 000000000000..c5004732dc01 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_xrange.pyi @@ -0,0 +1,20 @@ +from _typeshed import Incomplete +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixXrange(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + transformed_xranges: set[Incomplete] | None + def start_tree(self, tree, filename) -> None: ... + def finish_tree(self, tree, filename) -> None: ... + def transform(self, node, results): ... + def transform_xrange(self, node, results) -> None: ... + def transform_range(self, node, results): ... + P1: ClassVar[LiteralString] + p1: ClassVar[Incomplete] + P2: ClassVar[LiteralString] + p2: ClassVar[Incomplete] + def in_special_context(self, node): ... diff --git a/stdlib/lib2to3/fixes/fix_xreadlines.pyi b/stdlib/lib2to3/fixes/fix_xreadlines.pyi new file mode 100644 index 000000000000..3240cfa0041a --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_xreadlines.pyi @@ -0,0 +1,9 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixXreadlines(fixer_base.BaseFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_zip.pyi b/stdlib/lib2to3/fixes/fix_zip.pyi new file mode 100644 index 000000000000..0c30242c23d9 --- /dev/null +++ b/stdlib/lib2to3/fixes/fix_zip.pyi @@ -0,0 +1,10 @@ +from typing import ClassVar +from typing_extensions import Literal, LiteralString + +from .. import fixer_base + +class FixZip(fixer_base.ConditionalFix): + BM_compatible: ClassVar[Literal[True]] + PATTERN: ClassVar[LiteralString] + skip_on: ClassVar[Literal["future_builtins.zip"]] + def transform(self, node, results): ... diff --git a/stdlib/lib2to3/main.pyi b/stdlib/lib2to3/main.pyi new file mode 100644 index 000000000000..cfcaeeaf64ee --- /dev/null +++ b/stdlib/lib2to3/main.pyi @@ -0,0 +1,43 @@ +from _typeshed import FileDescriptorOrPath +from collections.abc import Container, Iterable, Iterator, Mapping, Sequence +from logging import _ExcInfoType +from typing import AnyStr +from typing_extensions import Literal + +from . import refactor as refactor + +def diff_texts(a: str, b: str, filename: str) -> Iterator[str]: ... + +class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool): + nobackups: bool + show_diffs: bool + def __init__( + self, + fixers: Iterable[str], + options: Mapping[str, object] | None, + explicit: Container[str] | None, + nobackups: bool, + show_diffs: bool, + input_base_dir: str = "", + output_dir: str = "", + append_suffix: str = "", + ) -> None: ... + # Same as super.log_error and Logger.error + def log_error( # type: ignore[override] + self, + msg: str, + *args: Iterable[str], + exc_info: _ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... + # Same as super.write_file but without default values + def write_file( # type: ignore[override] + self, new_text: str, filename: FileDescriptorOrPath, old_text: str, encoding: str | None + ) -> None: ... + # filename has to be str + def print_output(self, old: str, new: str, filename: str, equal: bool) -> None: ... # type: ignore[override] + +def warn(msg: object) -> None: ... +def main(fixer_pkg: str, args: Sequence[AnyStr] | None = None) -> Literal[0, 1, 2]: ... diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index 9f6e4d6774ad..ee6f880b736a 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -4,7 +4,7 @@ from lib2to3.pgen2 import _Convert from lib2to3.pgen2.grammar import Grammar from lib2to3.pytree import _NL from logging import Logger -from typing import IO, Any +from typing import IO __all__ = ["Driver", "load_grammar"] @@ -13,7 +13,9 @@ class Driver: logger: Logger convert: _Convert def __init__(self, grammar: Grammar, convert: _Convert | None = None, logger: Logger | None = None) -> None: ... - def parse_tokens(self, tokens: Iterable[Any], debug: bool = False) -> _NL: ... + def parse_tokens( + self, tokens: Iterable[tuple[int, str, tuple[int, int], tuple[int, int], str]], debug: bool = False + ) -> _NL: ... def parse_stream_raw(self, stream: IO[str], debug: bool = False) -> _NL: ... def parse_stream(self, stream: IO[str], debug: bool = False) -> _NL: ... def parse_file(self, filename: StrPath, encoding: str | None = None, debug: bool = False) -> _NL: ... diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index 51eb671f4236..410cca737f69 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,11 +1,11 @@ +from _typeshed import Incomplete from collections.abc import Sequence from lib2to3.pgen2 import _Convert from lib2to3.pgen2.grammar import _DFAS, Grammar from lib2to3.pytree import _NL, _RawNode -from typing import Any from typing_extensions import TypeAlias -_Context: TypeAlias = Sequence[Any] +_Context: TypeAlias = Sequence[Incomplete] class ParseError(Exception): msg: str diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index d346739d4d58..9afa91e17220 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,8 +1,8 @@ -from _typeshed import StrPath +from _typeshed import Incomplete, StrPath from collections.abc import Iterable, Iterator from lib2to3.pgen2 import grammar from lib2to3.pgen2.tokenize import _TokenInfo -from typing import IO, Any, NoReturn +from typing import IO, NoReturn, overload class PgenGrammar(grammar.Grammar): ... @@ -26,19 +26,22 @@ class ParserGenerator: def parse_alt(self) -> tuple[NFAState, NFAState]: ... def parse_item(self) -> tuple[NFAState, NFAState]: ... def parse_atom(self) -> tuple[NFAState, NFAState]: ... - def expect(self, type: int, value: Any | None = None) -> str: ... + def expect(self, type: int, value: str | None = None) -> str: ... def gettoken(self) -> None: ... - def raise_error(self, msg: str, *args: Any) -> NoReturn: ... + @overload + def raise_error(self, msg: object) -> NoReturn: ... + @overload + def raise_error(self, msg: str, *args: object) -> NoReturn: ... class NFAState: arcs: list[tuple[str | None, NFAState]] def addarc(self, next: NFAState, label: str | None = None) -> None: ... class DFAState: - nfaset: dict[NFAState, Any] + nfaset: dict[NFAState, Incomplete] isfinal: bool arcs: dict[str, DFAState] - def __init__(self, nfaset: dict[NFAState, Any], final: NFAState) -> None: ... + def __init__(self, nfaset: dict[NFAState, Incomplete], final: NFAState) -> None: ... def addarc(self, next: DFAState, label: str) -> None: ... def unifystate(self, old: DFAState, new: DFAState) -> None: ... def __eq__(self, other: DFAState) -> bool: ... # type: ignore[override] diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 4f756c9768db..8d525f1ca3b8 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,14 +1,17 @@ -from collections.abc import Iterator -from lib2to3.pgen2.grammar import Grammar -from typing import Any -from typing_extensions import Self, TypeAlias +from _typeshed import Incomplete, SupportsGetItem, SupportsLenAndGetItem, Unused +from abc import abstractmethod +from collections.abc import Iterable, Iterator, MutableSequence +from typing_extensions import Final, Self, TypeAlias + +from .fixer_base import BaseFix +from .pgen2.grammar import Grammar _NL: TypeAlias = Node | Leaf _Context: TypeAlias = tuple[str, int, int] _Results: TypeAlias = dict[str, _NL] _RawNode: TypeAlias = tuple[int, str, _Context, list[_NL] | None] -HUGE: int +HUGE: Final = 0x7FFFFFFF def type_repr(type_num: int) -> str: ... @@ -20,10 +23,14 @@ class Base: was_changed: bool was_checked: bool def __eq__(self, other: object) -> bool: ... - def _eq(self, other: Self) -> bool: ... + @abstractmethod + def _eq(self, other: Base) -> bool: ... + @abstractmethod def clone(self) -> Self: ... - def post_order(self) -> Iterator[_NL]: ... - def pre_order(self) -> Iterator[_NL]: ... + @abstractmethod + def post_order(self) -> Iterator[Self]: ... + @abstractmethod + def pre_order(self) -> Iterator[Self]: ... def replace(self, new: _NL | list[_NL]) -> None: ... def get_lineno(self) -> int: ... def changed(self) -> None: ... @@ -37,15 +44,21 @@ class Base: def get_suffix(self) -> str: ... class Node(Base): - fixers_applied: list[Any] + fixers_applied: MutableSequence[BaseFix] | None + # Is Unbound until set in refactor.RefactoringTool + future_features: frozenset[Incomplete] def __init__( self, type: int, - children: list[_NL], - context: Any | None = None, + children: Iterable[_NL], + context: Unused = None, prefix: str | None = None, - fixers_applied: list[Any] | None = None, + fixers_applied: MutableSequence[BaseFix] | None = None, ) -> None: ... + def _eq(self, other: Base) -> bool: ... + def clone(self) -> Node: ... + def post_order(self) -> Iterator[Self]: ... + def pre_order(self) -> Iterator[Self]: ... def set_child(self, i: int, child: _NL) -> None: ... def insert_child(self, i: int, child: _NL) -> None: ... def append_child(self, child: _NL) -> None: ... @@ -55,10 +68,19 @@ class Leaf(Base): lineno: int column: int value: str - fixers_applied: list[Any] + fixers_applied: MutableSequence[BaseFix] def __init__( - self, type: int, value: str, context: _Context | None = None, prefix: str | None = None, fixers_applied: list[Any] = ... + self, + type: int, + value: str, + context: _Context | None = None, + prefix: str | None = None, + fixers_applied: MutableSequence[BaseFix] = ..., ) -> None: ... + def _eq(self, other: Base) -> bool: ... + def clone(self) -> Leaf: ... + def post_order(self) -> Iterator[Self]: ... + def pre_order(self) -> Iterator[Self]: ... def __unicode__(self) -> str: ... def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... @@ -69,8 +91,8 @@ class BasePattern: name: str | None def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns def match(self, node: _NL, results: _Results | None = None) -> bool: ... - def match_seq(self, nodes: list[_NL], results: _Results | None = None) -> bool: ... - def generate_matches(self, nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ... + def match_seq(self, nodes: SupportsLenAndGetItem[_NL], results: _Results | None = None) -> bool: ... + def generate_matches(self, nodes: SupportsGetItem[int, _NL]) -> Iterator[tuple[int, _Results]]: ... class LeafPattern(BasePattern): def __init__(self, type: int | None = None, content: str | None = None, name: str | None = None) -> None: ... @@ -87,4 +109,6 @@ class WildcardPattern(BasePattern): class NegatedPattern(BasePattern): def __init__(self, content: str | None = None) -> None: ... -def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ... +def generate_matches( + patterns: SupportsGetItem[int | slice, BasePattern] | None, nodes: SupportsGetItem[int | slice, _NL] +) -> Iterator[tuple[int, _Results]]: ... diff --git a/stdlib/lib2to3/refactor.pyi b/stdlib/lib2to3/refactor.pyi index f1d89679aee7..9ba2e407d82f 100644 --- a/stdlib/lib2to3/refactor.pyi +++ b/stdlib/lib2to3/refactor.pyi @@ -1,12 +1,16 @@ +from _typeshed import FileDescriptorOrPath, StrPath, SupportsGetItem from collections.abc import Container, Generator, Iterable, Mapping -from logging import Logger -from typing import Any, ClassVar, NoReturn -from typing_extensions import TypeAlias +from lib2to3.btm_matcher import BottomMatcher +from lib2to3.pgen2.driver import Driver +from logging import Logger, _ExcInfoType +from multiprocessing import JoinableQueue +from multiprocessing.synchronize import Lock +from typing import Any, ClassVar, NoReturn, overload +from typing_extensions import Final +from .fixer_base import BaseFix from .pgen2.grammar import Grammar - -_Driver: TypeAlias = Any # really lib2to3.driver.Driver -_BottomMatcher: TypeAlias = Any # really lib2to3.btm_matcher.BottomMatcher +from .pytree import Node def get_all_fix_names(fixer_pkg: str, remove_prefix: bool = True) -> list[str]: ... def get_fixers_from_package(pkg_name: str) -> list[str]: ... @@ -21,53 +25,59 @@ class RefactoringTool: options: dict[str, Any] grammar: Grammar write_unchanged_files: bool - errors: list[Any] + errors: list[tuple[str, Iterable[str], dict[str, _ExcInfoType]]] logger: Logger - fixer_log: list[Any] + fixer_log: list[str] wrote: bool - driver: _Driver - pre_order: Any - post_order: Any - files: list[Any] - BM: _BottomMatcher - bmi_pre_order: list[Any] - bmi_post_order: list[Any] + driver: Driver + pre_order: list[BaseFix] + post_order: list[BaseFix] + files: list[StrPath] + BM: BottomMatcher + bmi_pre_order: list[BaseFix] + bmi_post_order: list[BaseFix] def __init__( - self, fixer_names: Iterable[str], options: Mapping[str, Any] | None = None, explicit: Container[str] | None = None + self, fixer_names: Iterable[str], options: Mapping[str, object] | None = None, explicit: Container[str] | None = None ) -> None: ... - def get_fixers(self) -> tuple[list[Any], list[Any]]: ... - def log_error(self, msg: str, *args: Any, **kwds: Any) -> NoReturn: ... - def log_message(self, msg: str, *args: Any) -> None: ... - def log_debug(self, msg: str, *args: Any) -> None: ... - def print_output(self, old_text: str, new_text: str, filename: str, equal): ... + def get_fixers(self) -> tuple[list[BaseFix], list[BaseFix]]: ... + def log_error(self, msg: str, *args: Iterable[str], **kwargs: _ExcInfoType) -> NoReturn: ... + @overload + def log_message(self, msg: object) -> None: ... + @overload + def log_message(self, msg: str, *args: object) -> None: ... + @overload + def log_debug(self, msg: object) -> None: ... + @overload + def log_debug(self, msg: str, *args: object) -> None: ... + def print_output(self, old_text: str, new_text: str, filename: StrPath, equal: bool) -> None: ... def refactor(self, items: Iterable[str], write: bool = False, doctests_only: bool = False) -> None: ... def refactor_dir(self, dir_name: str, write: bool = False, doctests_only: bool = False) -> None: ... - def _read_python_source(self, filename: str) -> tuple[str, str]: ... - def refactor_file(self, filename: str, write: bool = False, doctests_only: bool = False) -> None: ... - def refactor_string(self, data: str, name: str): ... + def _read_python_source(self, filename: FileDescriptorOrPath) -> tuple[str, str]: ... + def refactor_file(self, filename: StrPath, write: bool = False, doctests_only: bool = False) -> None: ... + def refactor_string(self, data: str, name: str) -> Node | None: ... def refactor_stdin(self, doctests_only: bool = False) -> None: ... - def refactor_tree(self, tree, name: str) -> bool: ... - def traverse_by(self, fixers, traversal) -> None: ... + def refactor_tree(self, tree: Node, name: str) -> bool: ... + def traverse_by(self, fixers: SupportsGetItem[int, Iterable[BaseFix]] | None, traversal: Iterable[Node]) -> None: ... def processed_file( - self, new_text: str, filename: str, old_text: str | None = None, write: bool = False, encoding: str | None = None + self, new_text: str, filename: StrPath, old_text: str | None = None, write: bool = False, encoding: str | None = None ) -> None: ... - def write_file(self, new_text: str, filename: str, old_text: str, encoding: str | None = None) -> None: ... - PS1: ClassVar[str] - PS2: ClassVar[str] - def refactor_docstring(self, input: str, filename: str) -> str: ... - def refactor_doctest(self, block: list[str], lineno: int, indent: int, filename: str) -> list[str]: ... + def write_file(self, new_text: str, filename: FileDescriptorOrPath, old_text: str, encoding: str | None = None) -> None: ... + PS1: Final = ">>> " + PS2: Final = "... " + def refactor_docstring(self, input: str, filename: StrPath) -> str: ... + def refactor_doctest(self, block: list[str], lineno: int, indent: int, filename: StrPath) -> list[str]: ... def summarize(self) -> None: ... - def parse_block(self, block: Iterable[str], lineno: int, indent: int): ... + def parse_block(self, block: Iterable[str], lineno: int, indent: int) -> Node: ... def wrap_toks( self, block: Iterable[str], lineno: int, indent: int - ) -> Generator[tuple[Any, Any, tuple[int, int], tuple[int, int], str], None, None]: ... + ) -> Generator[tuple[int, str, tuple[int, int], tuple[int, int], str], None, None]: ... def gen_lines(self, block: Iterable[str], indent: int) -> Generator[str, None, None]: ... class MultiprocessingUnsupported(Exception): ... class MultiprocessRefactoringTool(RefactoringTool): - queue: Any | None - output_lock: Any | None + queue: JoinableQueue[None | tuple[Iterable[str], bool | int]] | None + output_lock: Lock | None def refactor( self, items: Iterable[str], write: bool = False, doctests_only: bool = False, num_processes: int = 1 ) -> None: ... From 9fb647d8e5a42275994aafc4905970cfdc501e11 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 21 Feb 2023 01:54:18 -0500 Subject: [PATCH 2/6] missing BaseFix.pattern and otehr oopsies --- out/lib2to3/__init__.pyi | 0 out/lib2to3/btm_matcher.pyi | 25 ------ out/lib2to3/btm_utils.pyi | 30 ------- out/lib2to3/fixer_base.pyi | 37 -------- out/lib2to3/fixer_util.pyi | 46 ---------- out/lib2to3/main.pyi | 15 ---- out/lib2to3/patcomp.pyi | 25 ------ out/lib2to3/pgen2/__init__.pyi | 0 out/lib2to3/pgen2/conv.pyi | 16 ---- out/lib2to3/pgen2/driver.pyi | 14 --- out/lib2to3/pgen2/grammar.pyi | 24 ----- out/lib2to3/pgen2/literals.pyi | 7 -- out/lib2to3/pgen2/parse.pyi | 24 ----- out/lib2to3/pgen2/pgen.pyi | 45 ---------- out/lib2to3/pgen2/token.pyi | 69 -------------- out/lib2to3/pgen2/tokenize.pyi | 90 ------------------- out/lib2to3/pygram.pyi | 13 --- out/lib2to3/pytree.pyi | 110 ----------------------- out/lib2to3/refactor.pyi | 65 -------------- stdlib/lib2to3/fixer_base.pyi | 3 +- stdlib/lib2to3/fixes/fix_buffer.pyi | 1 - stdlib/lib2to3/fixes/fix_idioms.pyi | 1 - stdlib/lib2to3/fixes/fix_set_literal.pyi | 1 - stdlib/lib2to3/fixes/fix_ws_comma.pyi | 1 - 24 files changed, 2 insertions(+), 660 deletions(-) delete mode 100644 out/lib2to3/__init__.pyi delete mode 100644 out/lib2to3/btm_matcher.pyi delete mode 100644 out/lib2to3/btm_utils.pyi delete mode 100644 out/lib2to3/fixer_base.pyi delete mode 100644 out/lib2to3/fixer_util.pyi delete mode 100644 out/lib2to3/main.pyi delete mode 100644 out/lib2to3/patcomp.pyi delete mode 100644 out/lib2to3/pgen2/__init__.pyi delete mode 100644 out/lib2to3/pgen2/conv.pyi delete mode 100644 out/lib2to3/pgen2/driver.pyi delete mode 100644 out/lib2to3/pgen2/grammar.pyi delete mode 100644 out/lib2to3/pgen2/literals.pyi delete mode 100644 out/lib2to3/pgen2/parse.pyi delete mode 100644 out/lib2to3/pgen2/pgen.pyi delete mode 100644 out/lib2to3/pgen2/token.pyi delete mode 100644 out/lib2to3/pgen2/tokenize.pyi delete mode 100644 out/lib2to3/pygram.pyi delete mode 100644 out/lib2to3/pytree.pyi delete mode 100644 out/lib2to3/refactor.pyi diff --git a/out/lib2to3/__init__.pyi b/out/lib2to3/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/out/lib2to3/btm_matcher.pyi b/out/lib2to3/btm_matcher.pyi deleted file mode 100644 index bf6ea17f05f2..000000000000 --- a/out/lib2to3/btm_matcher.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from . import pytree as pytree -from .btm_utils import reduce_tree as reduce_tree -from _typeshed import Incomplete - -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) -> None: ... - def add(self, pattern, start): ... - def run(self, leaves): ... - def print_ac(self) -> None: ... - -def type_repr(type_num): ... diff --git a/out/lib2to3/btm_utils.pyi b/out/lib2to3/btm_utils.pyi deleted file mode 100644 index 1c1ad8398f4a..000000000000 --- a/out/lib2to3/btm_utils.pyi +++ /dev/null @@ -1,30 +0,0 @@ -from . import pytree as pytree -from .pgen2 import grammar as grammar, token as token -from .pygram import pattern_symbols as pattern_symbols, python_symbols as python_symbols -from _typeshed import Incomplete -from collections.abc import Generator - -syms = pattern_symbols -pysyms = python_symbols -tokens: Incomplete -token_labels = token -TYPE_ANY: int -TYPE_ALTERNATIVES: int -TYPE_GROUP: int - -class MinNode: - type: Incomplete - name: Incomplete - children: Incomplete - leaf: bool - parent: Incomplete - alternatives: Incomplete - group: Incomplete - def __init__(self, type: Incomplete | None = ..., name: Incomplete | None = ...) -> None: ... - def leaf_to_root(self): ... - def get_linear_subpattern(self): ... - def leaves(self) -> Generator[Incomplete, None, None]: ... - -def reduce_tree(node, parent: Incomplete | None = ...): ... -def get_characteristic_subpattern(subpatterns): ... -def rec_test(sequence, test_func) -> Generator[Incomplete, None, None]: ... diff --git a/out/lib2to3/fixer_base.pyi b/out/lib2to3/fixer_base.pyi deleted file mode 100644 index 00aa336cde4c..000000000000 --- a/out/lib2to3/fixer_base.pyi +++ /dev/null @@ -1,37 +0,0 @@ -from . import pygram as pygram -from .fixer_util import does_tree_import as does_tree_import -from .patcomp import PatternCompiler as PatternCompiler -from _typeshed import Incomplete - -class BaseFix: - PATTERN: Incomplete - pattern: Incomplete - pattern_tree: Incomplete - options: Incomplete - filename: Incomplete - numbers: Incomplete - used_names: Incomplete - order: str - explicit: bool - run_order: int - keep_line_order: bool - BM_compatible: bool - syms: Incomplete - log: Incomplete - def __init__(self, options, log) -> None: ... - def compile_pattern(self) -> None: ... - def set_filename(self, filename) -> None: ... - def match(self, node): ... - def transform(self, node, results) -> None: ... - def new_name(self, template: str = ...): ... - first_log: bool - def log_message(self, message) -> None: ... - def cannot_convert(self, node, reason: Incomplete | None = ...) -> None: ... - def warning(self, node, reason) -> None: ... - def start_tree(self, tree, filename) -> None: ... - def finish_tree(self, tree, filename) -> None: ... - -class ConditionalFix(BaseFix): - skip_on: Incomplete - def start_tree(self, *args) -> None: ... - def should_skip(self, node): ... diff --git a/out/lib2to3/fixer_util.pyi b/out/lib2to3/fixer_util.pyi deleted file mode 100644 index feb96daa74c7..000000000000 --- a/out/lib2to3/fixer_util.pyi +++ /dev/null @@ -1,46 +0,0 @@ -from . import patcomp as patcomp -from .pgen2 import token as token -from .pytree import Leaf as Leaf, Node as Node -from _typeshed import Incomplete -from collections.abc import Generator - -def KeywordArg(keyword, value): ... -def LParen(): ... -def RParen(): ... -def Assign(target, source): ... -def Name(name, prefix: Incomplete | None = ...): ... -def Attr(obj, attr): ... -def Comma(): ... -def Dot(): ... -def ArgList(args, lparen=..., rparen=...): ... -def Call(func_name, args: Incomplete | None = ..., prefix: Incomplete | None = ...): ... -def Newline(): ... -def BlankLine(): ... -def Number(n, prefix: Incomplete | None = ...): ... -def Subscript(index_node): ... -def String(string, prefix: Incomplete | None = ...): ... -def ListComp(xp, fp, it, test: Incomplete | None = ...): ... -def FromImport(package_name, name_leafs): ... -def ImportAndCall(node, results, names): ... -def is_tuple(node): ... -def is_list(node): ... -def parenthesize(node): ... - -consuming_calls: Incomplete - -def attr_chain(obj, attr) -> Generator[Incomplete, None, None]: ... - -p0: str -p1: str -p2: str -pats_built: bool - -def in_special_context(node): ... -def is_probably_builtin(node): ... -def find_indentation(node): ... -def make_suite(node): ... -def find_root(node): ... -def does_tree_import(package, name, node): ... -def is_import(node): ... -def touch_import(package, name, node): ... -def find_binding(name, node, package: Incomplete | None = ...): ... diff --git a/out/lib2to3/main.pyi b/out/lib2to3/main.pyi deleted file mode 100644 index 7168e899494d..000000000000 --- a/out/lib2to3/main.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from . import refactor as refactor -from _typeshed import Incomplete - -def diff_texts(a, b, filename): ... - -class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool): - nobackups: Incomplete - show_diffs: Incomplete - def __init__(self, fixers, options, explicit, nobackups, show_diffs, input_base_dir: str = ..., output_dir: str = ..., append_suffix: str = ...) -> None: ... - def log_error(self, msg, *args, **kwargs) -> None: ... - def write_file(self, new_text, filename, old_text, encoding) -> None: ... - def print_output(self, old, new, filename, equal) -> None: ... - -def warn(msg) -> None: ... -def main(fixer_pkg, args: Incomplete | None = ...): ... diff --git a/out/lib2to3/patcomp.pyi b/out/lib2to3/patcomp.pyi deleted file mode 100644 index 0221bcd60ce5..000000000000 --- a/out/lib2to3/patcomp.pyi +++ /dev/null @@ -1,25 +0,0 @@ -from . import pygram as pygram, pytree as pytree -from .pgen2 import driver as driver, grammar as grammar, literals as literals, parse as parse, token as token, tokenize as tokenize -from _typeshed import Incomplete -from collections.abc import Generator - -class PatternSyntaxError(Exception): ... - -def tokenize_wrapper(input) -> Generator[Incomplete, None, None]: ... - -class PatternCompiler: - grammar: Incomplete - syms: Incomplete - pygrammar: Incomplete - pysyms: Incomplete - driver: Incomplete - def __init__(self, grammar_file: Incomplete | None = ...) -> None: ... - def compile_pattern(self, input, debug: bool = ..., with_tree: bool = ...): ... - def compile_node(self, node): ... - def compile_basic(self, nodes, repeat: Incomplete | None = ...): ... - def get_int(self, node): ... - -TOKEN_MAP: Incomplete - -def pattern_convert(grammar, raw_node_info): ... -def compile_pattern(pattern): ... diff --git a/out/lib2to3/pgen2/__init__.pyi b/out/lib2to3/pgen2/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/out/lib2to3/pgen2/conv.pyi b/out/lib2to3/pgen2/conv.pyi deleted file mode 100644 index 5d0e28041368..000000000000 --- a/out/lib2to3/pgen2/conv.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from _typeshed import Incomplete -from pgen2 import grammar - -class Converter(grammar.Grammar): - def run(self, graminit_h, graminit_c) -> None: ... - symbol2number: Incomplete - number2symbol: Incomplete - def parse_graminit_h(self, filename): ... - states: Incomplete - dfas: Incomplete - labels: Incomplete - start: Incomplete - def parse_graminit_c(self, filename): ... - keywords: Incomplete - tokens: Incomplete - def finish_off(self) -> None: ... diff --git a/out/lib2to3/pgen2/driver.pyi b/out/lib2to3/pgen2/driver.pyi deleted file mode 100644 index 3f0c456be49c..000000000000 --- a/out/lib2to3/pgen2/driver.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from _typeshed import Incomplete - -class Driver: - grammar: Incomplete - logger: Incomplete - convert: Incomplete - def __init__(self, grammar, convert: Incomplete | None = ..., logger: Incomplete | None = ...) -> None: ... - def parse_tokens(self, tokens, debug: bool = ...): ... - def parse_stream_raw(self, stream, debug: bool = ...): ... - def parse_stream(self, stream, debug: bool = ...): ... - def parse_file(self, filename, encoding: Incomplete | None = ..., debug: bool = ...): ... - def parse_string(self, text, debug: bool = ...): ... - -def load_grammar(gt: str = ..., gp: Incomplete | None = ..., save: bool = ..., force: bool = ..., logger: Incomplete | None = ...): ... diff --git a/out/lib2to3/pgen2/grammar.pyi b/out/lib2to3/pgen2/grammar.pyi deleted file mode 100644 index 751b86dd586e..000000000000 --- a/out/lib2to3/pgen2/grammar.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from . import token as token -from _typeshed import Incomplete - -class Grammar: - symbol2number: Incomplete - number2symbol: Incomplete - states: Incomplete - dfas: Incomplete - labels: Incomplete - keywords: Incomplete - tokens: Incomplete - symbol2label: Incomplete - start: int - def __init__(self) -> None: ... - def dump(self, filename) -> None: ... - def load(self, filename) -> None: ... - def loads(self, pkl) -> None: ... - def copy(self): ... - def report(self) -> None: ... - -opmap_raw: str -opmap: Incomplete -op: Incomplete -name: Incomplete diff --git a/out/lib2to3/pgen2/literals.pyi b/out/lib2to3/pgen2/literals.pyi deleted file mode 100644 index 1a53c10d890e..000000000000 --- a/out/lib2to3/pgen2/literals.pyi +++ /dev/null @@ -1,7 +0,0 @@ -from _typeshed import Incomplete - -simple_escapes: Incomplete - -def escape(m): ... -def evalString(s): ... -def test() -> None: ... diff --git a/out/lib2to3/pgen2/parse.pyi b/out/lib2to3/pgen2/parse.pyi deleted file mode 100644 index ccedec07cbe4..000000000000 --- a/out/lib2to3/pgen2/parse.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from . import token as token -from _typeshed import Incomplete - -class ParseError(Exception): - msg: Incomplete - type: Incomplete - value: Incomplete - context: Incomplete - def __init__(self, msg, type, value, context) -> None: ... - def __reduce__(self): ... - -class Parser: - grammar: Incomplete - convert: Incomplete - def __init__(self, grammar, convert: Incomplete | None = ...) -> None: ... - stack: Incomplete - rootnode: Incomplete - used_names: Incomplete - def setup(self, start: Incomplete | None = ...) -> None: ... - def addtoken(self, type, value, context): ... - def classify(self, type, value, context): ... - def shift(self, type, value, newstate, context) -> None: ... - def push(self, type, newdfa, newstate, context) -> None: ... - def pop(self) -> None: ... diff --git a/out/lib2to3/pgen2/pgen.pyi b/out/lib2to3/pgen2/pgen.pyi deleted file mode 100644 index 5556fff301db..000000000000 --- a/out/lib2to3/pgen2/pgen.pyi +++ /dev/null @@ -1,45 +0,0 @@ -from . import grammar as grammar, token as token, tokenize as tokenize -from _typeshed import Incomplete - -class PgenGrammar(grammar.Grammar): ... - -class ParserGenerator: - filename: Incomplete - stream: Incomplete - generator: Incomplete - first: Incomplete - def __init__(self, filename, stream: Incomplete | None = ...) -> None: ... - def make_grammar(self): ... - def make_first(self, c, name): ... - def make_label(self, c, label): ... - def addfirstsets(self) -> None: ... - def calcfirst(self, name) -> None: ... - def parse(self): ... - def make_dfa(self, start, finish): ... - def dump_nfa(self, name, start, finish) -> None: ... - def dump_dfa(self, name, dfa) -> None: ... - def simplify_dfa(self, dfa) -> None: ... - def parse_rhs(self): ... - def parse_alt(self): ... - def parse_item(self): ... - def parse_atom(self): ... - def expect(self, type, value: Incomplete | None = ...): ... - def gettoken(self) -> None: ... - def raise_error(self, msg, *args) -> None: ... - -class NFAState: - arcs: Incomplete - def __init__(self) -> None: ... - def addarc(self, next, label: Incomplete | None = ...) -> None: ... - -class DFAState: - nfaset: Incomplete - isfinal: Incomplete - arcs: Incomplete - def __init__(self, nfaset, final) -> None: ... - def addarc(self, next, label) -> None: ... - def unifystate(self, old, new) -> None: ... - def __eq__(self, other): ... - __hash__: Incomplete - -def generate_grammar(filename: str = ...): ... diff --git a/out/lib2to3/pgen2/token.pyi b/out/lib2to3/pgen2/token.pyi deleted file mode 100644 index c4308fdc533d..000000000000 --- a/out/lib2to3/pgen2/token.pyi +++ /dev/null @@ -1,69 +0,0 @@ -from _typeshed import Incomplete - -ENDMARKER: int -NAME: int -NUMBER: int -STRING: int -NEWLINE: int -INDENT: int -DEDENT: int -LPAR: int -RPAR: int -LSQB: int -RSQB: int -COLON: int -COMMA: int -SEMI: int -PLUS: int -MINUS: int -STAR: int -SLASH: int -VBAR: int -AMPER: int -LESS: int -GREATER: int -EQUAL: int -DOT: int -PERCENT: int -BACKQUOTE: int -LBRACE: int -RBRACE: int -EQEQUAL: int -NOTEQUAL: int -LESSEQUAL: int -GREATEREQUAL: int -TILDE: int -CIRCUMFLEX: int -LEFTSHIFT: int -RIGHTSHIFT: int -DOUBLESTAR: int -PLUSEQUAL: int -MINEQUAL: int -STAREQUAL: int -SLASHEQUAL: int -PERCENTEQUAL: int -AMPEREQUAL: int -VBAREQUAL: int -CIRCUMFLEXEQUAL: int -LEFTSHIFTEQUAL: int -RIGHTSHIFTEQUAL: int -DOUBLESTAREQUAL: int -DOUBLESLASH: int -DOUBLESLASHEQUAL: int -AT: int -ATEQUAL: int -OP: int -COMMENT: int -NL: int -RARROW: int -AWAIT: int -ASYNC: int -ERRORTOKEN: int -COLONEQUAL: int -N_TOKENS: int -NT_OFFSET: int -tok_name: Incomplete - -def ISTERMINAL(x): ... -def ISNONTERMINAL(x): ... -def ISEOF(x): ... diff --git a/out/lib2to3/pgen2/tokenize.pyi b/out/lib2to3/pgen2/tokenize.pyi deleted file mode 100644 index eea1852a1912..000000000000 --- a/out/lib2to3/pgen2/tokenize.pyi +++ /dev/null @@ -1,90 +0,0 @@ -from lib2to3.pgen2.token import * -from _typeshed import Incomplete -from collections.abc import Generator - -bytes = str - -class TokenError(Exception): ... -class StopTokenizing(Exception): ... - -def tokenize(readline, tokeneater=...) -> None: ... - -class Untokenizer: - tokens: Incomplete - prev_row: int - prev_col: int - def __init__(self) -> None: ... - def add_whitespace(self, start) -> None: ... - def untokenize(self, iterable): ... - def compat(self, token, iterable) -> None: ... - -def untokenize(iterable): ... -def generate_tokens(readline) -> Generator[Incomplete, None, None]: ... - -# Names in __all__ with no definition: -# AMPER -# AMPEREQUAL -# ASYNC -# AT -# ATEQUAL -# AWAIT -# BACKQUOTE -# CIRCUMFLEX -# CIRCUMFLEXEQUAL -# COLON -# COLONEQUAL -# COMMA -# COMMENT -# DEDENT -# DOT -# DOUBLESLASH -# DOUBLESLASHEQUAL -# DOUBLESTAR -# DOUBLESTAREQUAL -# ENDMARKER -# EQEQUAL -# EQUAL -# ERRORTOKEN -# GREATER -# GREATEREQUAL -# INDENT -# ISEOF -# ISNONTERMINAL -# ISTERMINAL -# LBRACE -# LEFTSHIFT -# LEFTSHIFTEQUAL -# LESS -# LESSEQUAL -# LPAR -# LSQB -# MINEQUAL -# MINUS -# NAME -# NEWLINE -# NL -# NOTEQUAL -# NT_OFFSET -# NUMBER -# N_TOKENS -# OP -# PERCENT -# PERCENTEQUAL -# PLUS -# PLUSEQUAL -# RARROW -# RBRACE -# RIGHTSHIFT -# RIGHTSHIFTEQUAL -# RPAR -# RSQB -# SEMI -# SLASH -# SLASHEQUAL -# STAR -# STAREQUAL -# STRING -# TILDE -# VBAR -# VBAREQUAL -# tok_name diff --git a/out/lib2to3/pygram.pyi b/out/lib2to3/pygram.pyi deleted file mode 100644 index 3702caa59ee1..000000000000 --- a/out/lib2to3/pygram.pyi +++ /dev/null @@ -1,13 +0,0 @@ -from . import pytree as pytree -from .pgen2 import driver as driver, token as token -from _typeshed import Incomplete - -class Symbols: - def __init__(self, grammar) -> None: ... - -python_grammar: Incomplete -python_symbols: Incomplete -python_grammar_no_print_statement: Incomplete -python_grammar_no_print_and_exec_statement: Incomplete -pattern_grammar: Incomplete -pattern_symbols: Incomplete diff --git a/out/lib2to3/pytree.pyi b/out/lib2to3/pytree.pyi deleted file mode 100644 index 3cb1382f5350..000000000000 --- a/out/lib2to3/pytree.pyi +++ /dev/null @@ -1,110 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Generator - -HUGE: int - -def type_repr(type_num): ... - -class Base: - type: Incomplete - parent: Incomplete - children: Incomplete - was_changed: bool - was_checked: bool - def __new__(cls, *args, **kwds): ... - def __eq__(self, other): ... - __hash__: Incomplete - def clone(self) -> None: ... - def post_order(self) -> None: ... - def pre_order(self) -> None: ... - def replace(self, new) -> None: ... - def get_lineno(self): ... - def changed(self) -> None: ... - def remove(self): ... - @property - def next_sibling(self): ... - @property - def prev_sibling(self): ... - def leaves(self) -> None: ... - def depth(self): ... - def get_suffix(self): ... - -class Node(Base): - type: Incomplete - children: Incomplete - fixers_applied: Incomplete - def __init__(self, type, children, context: Incomplete | None = ..., prefix: Incomplete | None = ..., fixers_applied: Incomplete | None = ...) -> None: ... - def __unicode__(self): ... - def clone(self): ... - def post_order(self) -> Generator[Incomplete, None, None]: ... - def pre_order(self) -> Generator[Incomplete, None, None]: ... - @property - def prefix(self): ... - @prefix.setter - def prefix(self, prefix) -> None: ... - def set_child(self, i, child) -> None: ... - def insert_child(self, i, child) -> None: ... - def append_child(self, child) -> None: ... - -class Leaf(Base): - lineno: int - column: int - type: Incomplete - value: Incomplete - fixers_applied: Incomplete - def __init__(self, type, value, context: Incomplete | None = ..., prefix: Incomplete | None = ..., fixers_applied=...) -> None: ... - def __unicode__(self): ... - def clone(self): ... - def leaves(self) -> Generator[Incomplete, None, None]: ... - def post_order(self) -> Generator[Incomplete, None, None]: ... - def pre_order(self) -> Generator[Incomplete, None, None]: ... - @property - def prefix(self): ... - @prefix.setter - def prefix(self, prefix) -> None: ... - -def convert(gr, raw_node): ... - -class BasePattern: - type: Incomplete - content: Incomplete - name: Incomplete - def __new__(cls, *args, **kwds): ... - def optimize(self): ... - def match(self, node, results: Incomplete | None = ...): ... - def match_seq(self, nodes, results: Incomplete | None = ...): ... - def generate_matches(self, nodes) -> Generator[Incomplete, None, None]: ... - -class LeafPattern(BasePattern): - type: Incomplete - content: Incomplete - name: Incomplete - def __init__(self, type: Incomplete | None = ..., content: Incomplete | None = ..., name: Incomplete | None = ...) -> None: ... - def match(self, node, results: Incomplete | None = ...): ... - -class NodePattern(BasePattern): - wildcards: bool - type: Incomplete - content: Incomplete - name: Incomplete - def __init__(self, type: Incomplete | None = ..., content: Incomplete | None = ..., name: Incomplete | None = ...) -> None: ... - -class WildcardPattern(BasePattern): - content: Incomplete - min: Incomplete - max: Incomplete - name: Incomplete - def __init__(self, content: Incomplete | None = ..., min: int = ..., max=..., name: Incomplete | None = ...) -> None: ... - def optimize(self): ... - def match(self, node, results: Incomplete | None = ...): ... - def match_seq(self, nodes, results: Incomplete | None = ...): ... - def generate_matches(self, nodes) -> Generator[Incomplete, None, None]: ... - -class NegatedPattern(BasePattern): - content: Incomplete - def __init__(self, content: Incomplete | None = ...) -> None: ... - def match(self, node): ... - def match_seq(self, nodes): ... - def generate_matches(self, nodes) -> Generator[Incomplete, None, None]: ... - -def generate_matches(patterns, nodes) -> Generator[Incomplete, None, None]: ... diff --git a/out/lib2to3/refactor.pyi b/out/lib2to3/refactor.pyi deleted file mode 100644 index 959a6fd07ef6..000000000000 --- a/out/lib2to3/refactor.pyi +++ /dev/null @@ -1,65 +0,0 @@ -from . import pygram as pygram, pytree as pytree -from .fixer_util import find_root as find_root -from .pgen2 import driver as driver, token as token, tokenize as tokenize -from _typeshed import Incomplete -from collections.abc import Generator, Iterable as Iterable - -def get_all_fix_names(fixer_pkg, remove_prefix: bool = ...): ... - -class _EveryNode(Exception): ... - -def get_fixers_from_package(pkg_name): ... - -class FixerError(Exception): ... - -class RefactoringTool: - CLASS_PREFIX: str - FILE_PREFIX: str - fixers: Incomplete - explicit: Incomplete - options: Incomplete - grammar: Incomplete - write_unchanged_files: Incomplete - errors: Incomplete - logger: Incomplete - fixer_log: Incomplete - wrote: bool - driver: Incomplete - files: Incomplete - BM: Incomplete - bmi_pre_order: Incomplete - bmi_post_order: Incomplete - bmi_pre_order_heads: Incomplete - bmi_post_order_heads: Incomplete - def __init__(self, fixer_names, options: Incomplete | None = ..., explicit: Incomplete | None = ...) -> None: ... - def get_fixers(self): ... - def log_error(self, msg, *args, **kwds) -> None: ... - def log_message(self, msg, *args) -> None: ... - def log_debug(self, msg, *args) -> None: ... - def print_output(self, old_text, new_text, filename, equal) -> None: ... - def refactor(self, items, write: bool = ..., doctests_only: bool = ...) -> None: ... - def refactor_dir(self, dir_name, write: bool = ..., doctests_only: bool = ...) -> None: ... - def refactor_file(self, filename, write: bool = ..., doctests_only: bool = ...) -> None: ... - def refactor_string(self, data, name): ... - def refactor_stdin(self, doctests_only: bool = ...) -> None: ... - def refactor_tree(self, tree, name): ... - def traverse_by(self, fixers, traversal) -> None: ... - def processed_file(self, new_text, filename, old_text: Incomplete | None = ..., write: bool = ..., encoding: Incomplete | None = ...) -> None: ... - def write_file(self, new_text, filename, old_text, encoding: Incomplete | None = ...) -> None: ... - PS1: str - PS2: str - def refactor_docstring(self, input, filename): ... - def refactor_doctest(self, block, lineno, indent, filename): ... - def summarize(self) -> None: ... - def parse_block(self, block, lineno, indent): ... - def wrap_toks(self, block, lineno, indent) -> Generator[Incomplete, None, None]: ... - def gen_lines(self, block, indent) -> Generator[Incomplete, None, None]: ... - -class MultiprocessingUnsupported(Exception): ... - -class MultiprocessRefactoringTool(RefactoringTool): - queue: Incomplete - output_lock: Incomplete - def __init__(self, *args, **kwargs) -> None: ... - def refactor(self, items, write: bool = ..., doctests_only: bool = ..., num_processes: int = ...): ... - def refactor_file(self, *args, **kwargs): ... diff --git a/stdlib/lib2to3/fixer_base.pyi b/stdlib/lib2to3/fixer_base.pyi index c045d096ed34..e581d5a3913e 100644 --- a/stdlib/lib2to3/fixer_base.pyi +++ b/stdlib/lib2to3/fixer_base.pyi @@ -9,13 +9,14 @@ _N = TypeVar("_N", bound=Base) class BaseFix: PATTERN: ClassVar[LiteralString | 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: bool + explicit: ClassVar[bool] run_order: ClassVar[int] keep_line_order: ClassVar[bool] BM_compatible: ClassVar[bool] diff --git a/stdlib/lib2to3/fixes/fix_buffer.pyi b/stdlib/lib2to3/fixes/fix_buffer.pyi index b601e9cabfc3..62804ece4197 100644 --- a/stdlib/lib2to3/fixes/fix_buffer.pyi +++ b/stdlib/lib2to3/fixes/fix_buffer.pyi @@ -5,6 +5,5 @@ from .. import fixer_base class FixBuffer(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - explicit: bool PATTERN: ClassVar[LiteralString] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_idioms.pyi b/stdlib/lib2to3/fixes/fix_idioms.pyi index e0ad60d555c1..8914dd243f3b 100644 --- a/stdlib/lib2to3/fixes/fix_idioms.pyi +++ b/stdlib/lib2to3/fixes/fix_idioms.pyi @@ -8,7 +8,6 @@ TYPE: str class FixIdioms(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[False]] - explicit: bool PATTERN: ClassVar[LiteralString] def match(self, node): ... def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_set_literal.pyi b/stdlib/lib2to3/fixes/fix_set_literal.pyi index b1f1e86b95a4..f946ac9c5a5d 100644 --- a/stdlib/lib2to3/fixes/fix_set_literal.pyi +++ b/stdlib/lib2to3/fixes/fix_set_literal.pyi @@ -4,6 +4,5 @@ from typing_extensions import Literal, LiteralString class FixSetLiteral(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - explicit: bool PATTERN: ClassVar[LiteralString] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_ws_comma.pyi b/stdlib/lib2to3/fixes/fix_ws_comma.pyi index 2e60d1656350..3d4a911460f2 100644 --- a/stdlib/lib2to3/fixes/fix_ws_comma.pyi +++ b/stdlib/lib2to3/fixes/fix_ws_comma.pyi @@ -6,7 +6,6 @@ from ..pytree import Leaf class FixWsComma(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[False]] - explicit: bool PATTERN: ClassVar[LiteralString] COMMA: Leaf COLON: Leaf From 65185f8d5a86752a688e0c4ba572e6675bc80047 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 3 Apr 2023 12:34:38 -0400 Subject: [PATCH 3/6] Complete fixer_base.pyi --- pyrightconfig.stricter.json | 1 - stdlib/lib2to3/fixer_base.pyi | 19 ++++++++++--------- stdlib/lib2to3/fixes/fix_exitfunc.pyi | 5 +++-- stdlib/lib2to3/fixes/fix_import.pyi | 4 +++- stdlib/lib2to3/fixes/fix_imports.pyi | 4 +++- stdlib/lib2to3/fixes/fix_next.pyi | 4 +++- stdlib/lib2to3/fixes/fix_unicode.pyi | 4 +++- stdlib/lib2to3/fixes/fix_xrange.pyi | 7 ++++--- stdlib/lib2to3/pytree.pyi | 2 ++ 9 files changed, 31 insertions(+), 19 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index ecd496040ae6..a09066c14924 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -10,7 +10,6 @@ "stubs/**/@tests/test_cases", "stdlib/distutils/command", "stdlib/distutils/dist.pyi", - "stdlib/lib2to3/fixer_base.pyi", "stdlib/lib2to3/fixes/*.pyi", "stdlib/_tkinter.pyi", "stdlib/tkinter/__init__.pyi", diff --git a/stdlib/lib2to3/fixer_base.pyi b/stdlib/lib2to3/fixer_base.pyi index e581d5a3913e..3ac30e04946e 100644 --- a/stdlib/lib2to3/fixer_base.pyi +++ b/stdlib/lib2to3/fixer_base.pyi @@ -1,5 +1,6 @@ -from _typeshed import Incomplete +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, LiteralString @@ -22,21 +23,21 @@ class BaseFix: BM_compatible: ClassVar[bool] syms: Incomplete log: Incomplete - def __init__(self, options, log) -> None: ... + def __init__(self, options: MutableMapping[str, Incomplete], log: list[str]) -> None: ... def compile_pattern(self) -> None: ... - def set_filename(self, filename) -> 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) -> None: ... - def cannot_convert(self, node: Base, reason: Incomplete | None = None) -> None: ... - def warning(self, node: Base, reason) -> None: ... - def start_tree(self, tree, filename) -> None: ... - def finish_tree(self, tree, filename) -> None: ... + 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[LiteralString | None] - def start_tree(self, *args) -> None: ... + def start_tree(self, __tree: Node, __filename: StrPath) -> None: ... def should_skip(self, node: Base) -> bool: ... diff --git a/stdlib/lib2to3/fixes/fix_exitfunc.pyi b/stdlib/lib2to3/fixes/fix_exitfunc.pyi index 6746aa057b35..1e2ae2783302 100644 --- a/stdlib/lib2to3/fixes/fix_exitfunc.pyi +++ b/stdlib/lib2to3/fixes/fix_exitfunc.pyi @@ -1,5 +1,6 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath from lib2to3 import fixer_base +from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal, LiteralString @@ -8,5 +9,5 @@ class FixExitfunc(fixer_base.BaseFix): PATTERN: ClassVar[LiteralString] def __init__(self, *args) -> None: ... sys_import: Incomplete | None - def start_tree(self, tree, filename) -> None: ... + def start_tree(self, tree: Node, filename: StrPath) -> None: ... def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_import.pyi b/stdlib/lib2to3/fixes/fix_import.pyi index b57f4c8d7442..5e97af4a8362 100644 --- a/stdlib/lib2to3/fixes/fix_import.pyi +++ b/stdlib/lib2to3/fixes/fix_import.pyi @@ -1,4 +1,6 @@ +from _typeshed import StrPath from collections.abc import Generator +from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal, LiteralString @@ -10,6 +12,6 @@ class FixImport(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] PATTERN: ClassVar[LiteralString] skip: bool - def start_tree(self, tree, name) -> None: ... + def start_tree(self, tree: Node, name: StrPath) -> None: ... def transform(self, node, results): ... def probably_a_local_import(self, imp_name): ... diff --git a/stdlib/lib2to3/fixes/fix_imports.pyi b/stdlib/lib2to3/fixes/fix_imports.pyi index c36d68d21cd7..2fa1f94a50d4 100644 --- a/stdlib/lib2to3/fixes/fix_imports.pyi +++ b/stdlib/lib2to3/fixes/fix_imports.pyi @@ -1,4 +1,6 @@ +from _typeshed import StrPath from collections.abc import Generator +from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal @@ -16,5 +18,5 @@ class FixImports(fixer_base.BaseFix): def compile_pattern(self) -> None: ... def match(self, node): ... replace: dict[str, str] - def start_tree(self, tree, filename) -> None: ... + def start_tree(self, tree: Node, filename: StrPath) -> None: ... def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_next.pyi b/stdlib/lib2to3/fixes/fix_next.pyi index 88eb664ae38e..6ea7b33188e5 100644 --- a/stdlib/lib2to3/fixes/fix_next.pyi +++ b/stdlib/lib2to3/fixes/fix_next.pyi @@ -1,3 +1,5 @@ +from _typeshed import StrPath +from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal, LiteralString @@ -10,7 +12,7 @@ class FixNext(fixer_base.BaseFix): PATTERN: ClassVar[LiteralString] order: ClassVar[Literal["pre"]] shadowed_next: bool - def start_tree(self, tree, filename) -> None: ... + def start_tree(self, tree: Node, filename: StrPath) -> None: ... def transform(self, node, results) -> None: ... def is_assign_target(node): ... diff --git a/stdlib/lib2to3/fixes/fix_unicode.pyi b/stdlib/lib2to3/fixes/fix_unicode.pyi index 2ae935cb9881..86d787ddff25 100644 --- a/stdlib/lib2to3/fixes/fix_unicode.pyi +++ b/stdlib/lib2to3/fixes/fix_unicode.pyi @@ -1,3 +1,5 @@ +from _typeshed import StrPath +from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal @@ -7,5 +9,5 @@ class FixUnicode(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] PATTERN: ClassVar[Literal["STRING | 'unicode' | 'unichr'"]] # type: ignore[name-defined] # Name "STRING" is not defined unicode_literals: bool - def start_tree(self, tree, filename) -> None: ... + def start_tree(self, tree: Node, filename: StrPath) -> None: ... def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_xrange.pyi b/stdlib/lib2to3/fixes/fix_xrange.pyi index c5004732dc01..afe3be2869dc 100644 --- a/stdlib/lib2to3/fixes/fix_xrange.pyi +++ b/stdlib/lib2to3/fixes/fix_xrange.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath +from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal, LiteralString @@ -8,8 +9,8 @@ class FixXrange(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] PATTERN: ClassVar[LiteralString] transformed_xranges: set[Incomplete] | None - def start_tree(self, tree, filename) -> None: ... - def finish_tree(self, tree, filename) -> None: ... + def start_tree(self, tree: Node, filename: StrPath) -> None: ... + def finish_tree(self, tree: Node, filename: StrPath) -> None: ... def transform(self, node, results): ... def transform_xrange(self, node, results) -> None: ... def transform_range(self, node, results): ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 74a2fea352f4..2cb8edb7dfd7 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -47,6 +47,8 @@ class Node(Base): fixers_applied: MutableSequence[BaseFix] | None # Is Unbound until set in refactor.RefactoringTool future_features: frozenset[Incomplete] + # Is Unbound until set in pgen2.parse.Parser.pop + used_names: set[str] def __init__( self, type: int, From 828cea00455d9d97f9f5e53f843656fed71c0966 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 27 Apr 2023 23:39:47 -0400 Subject: [PATCH 4/6] Address PR comments --- stdlib/lib2to3/btm_matcher.pyi | 2 +- stdlib/lib2to3/fixer_base.pyi | 6 +++--- stdlib/lib2to3/fixes/fix_apply.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_asserts.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_buffer.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_dict.pyi | 8 ++++---- stdlib/lib2to3/fixes/fix_except.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_exec.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_execfile.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_exitfunc.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_filter.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_funcattrs.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_future.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_getcwdu.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_has_key.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_idioms.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_import.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_input.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_intern.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_isinstance.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_itertools.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_itertools_imports.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_map.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_metaclass.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_methodattrs.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_next.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_nonzero.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_operator.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_paren.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_print.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_raise.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_raw_input.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_reduce.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_reload.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_renames.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_repr.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_set_literal.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_standarderror.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_sys_exc.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_throw.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_tuple_params.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_types.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_ws_comma.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_xrange.pyi | 8 ++++---- stdlib/lib2to3/fixes/fix_xreadlines.pyi | 4 ++-- stdlib/lib2to3/fixes/fix_zip.pyi | 4 ++-- stdlib/lib2to3/pytree.pyi | 2 +- 47 files changed, 97 insertions(+), 97 deletions(-) diff --git a/stdlib/lib2to3/btm_matcher.pyi b/stdlib/lib2to3/btm_matcher.pyi index 9b320ef1ed37..e7bf8f78125c 100644 --- a/stdlib/lib2to3/btm_matcher.pyi +++ b/stdlib/lib2to3/btm_matcher.pyi @@ -27,4 +27,4 @@ class BottomMatcher: def run(self, leaves: Iterable[Leaf]) -> defaultdict[BaseFix, list[Node | Leaf]]: ... def print_ac(self) -> None: ... -def type_repr(type_num: _T) -> _T: ... +def type_repr(type_num: int) -> str | int: ... diff --git a/stdlib/lib2to3/fixer_base.pyi b/stdlib/lib2to3/fixer_base.pyi index 3ac30e04946e..eef386f709ac 100644 --- a/stdlib/lib2to3/fixer_base.pyi +++ b/stdlib/lib2to3/fixer_base.pyi @@ -2,14 +2,14 @@ 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, LiteralString +from typing_extensions import Literal from .pytree import Base, Leaf, Node _N = TypeVar("_N", bound=Base) class BaseFix: - PATTERN: ClassVar[LiteralString | None] + PATTERN: ClassVar[str | None] pattern: Incomplete | None pattern_tree: Incomplete | None options: Incomplete | None @@ -38,6 +38,6 @@ class BaseFix: def finish_tree(self, tree: Node, filename: StrPath) -> None: ... class ConditionalFix(BaseFix, metaclass=ABCMeta): - skip_on: ClassVar[LiteralString | None] + skip_on: ClassVar[str | None] def start_tree(self, __tree: Node, __filename: StrPath) -> None: ... def should_skip(self, node: Base) -> bool: ... diff --git a/stdlib/lib2to3/fixes/fix_apply.pyi b/stdlib/lib2to3/fixes/fix_apply.pyi index d7255d9def43..7c5451c15220 100644 --- a/stdlib/lib2to3/fixes/fix_apply.pyi +++ b/stdlib/lib2to3/fixes/fix_apply.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixApply(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_asserts.pyi b/stdlib/lib2to3/fixes/fix_asserts.pyi index 6f982e6d7946..bf73009e9dbf 100644 --- a/stdlib/lib2to3/fixes/fix_asserts.pyi +++ b/stdlib/lib2to3/fixes/fix_asserts.pyi @@ -1,5 +1,5 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from ..fixer_base import BaseFix @@ -7,5 +7,5 @@ NAMES: dict[str, str] class FixAsserts(BaseFix): BM_compatible: ClassVar[Literal[False]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_buffer.pyi b/stdlib/lib2to3/fixes/fix_buffer.pyi index 62804ece4197..857c1e2241b9 100644 --- a/stdlib/lib2to3/fixes/fix_buffer.pyi +++ b/stdlib/lib2to3/fixes/fix_buffer.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixBuffer(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_dict.pyi b/stdlib/lib2to3/fixes/fix_dict.pyi index a95cef107684..2e66911195bf 100644 --- a/stdlib/lib2to3/fixes/fix_dict.pyi +++ b/stdlib/lib2to3/fixes/fix_dict.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -8,10 +8,10 @@ iter_exempt: set[str] class FixDict(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... - P1: ClassVar[LiteralString] + P1: ClassVar[str] p1: ClassVar[Incomplete] - P2: ClassVar[LiteralString] + P2: ClassVar[str] p2: ClassVar[Incomplete] def in_special_context(self, node, isiter): ... diff --git a/stdlib/lib2to3/fixes/fix_except.pyi b/stdlib/lib2to3/fixes/fix_except.pyi index efd925d6e9f1..ca37de03bbca 100644 --- a/stdlib/lib2to3/fixes/fix_except.pyi +++ b/stdlib/lib2to3/fixes/fix_except.pyi @@ -1,7 +1,7 @@ from collections.abc import Generator, Iterable from lib2to3.pytree import Base from typing import ClassVar, TypeVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -11,5 +11,5 @@ def find_excepts(nodes: Iterable[_N]) -> Generator[tuple[_N, _N], None, None]: . class FixExcept(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_exec.pyi b/stdlib/lib2to3/fixes/fix_exec.pyi index 2c3c2fabda9c..306937eb9759 100644 --- a/stdlib/lib2to3/fixes/fix_exec.pyi +++ b/stdlib/lib2to3/fixes/fix_exec.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixExec(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_execfile.pyi b/stdlib/lib2to3/fixes/fix_execfile.pyi index e90f001714cb..fb245e5a1c1c 100644 --- a/stdlib/lib2to3/fixes/fix_execfile.pyi +++ b/stdlib/lib2to3/fixes/fix_execfile.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixExecfile(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_exitfunc.pyi b/stdlib/lib2to3/fixes/fix_exitfunc.pyi index 1e2ae2783302..9c5434dad079 100644 --- a/stdlib/lib2to3/fixes/fix_exitfunc.pyi +++ b/stdlib/lib2to3/fixes/fix_exitfunc.pyi @@ -2,11 +2,11 @@ from _typeshed import Incomplete, StrPath from lib2to3 import fixer_base from lib2to3.pytree import Node from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal class FixExitfunc(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def __init__(self, *args) -> None: ... sys_import: Incomplete | None def start_tree(self, tree: Node, filename: StrPath) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_filter.pyi b/stdlib/lib2to3/fixes/fix_filter.pyi index 18357f808837..3998a1dd001e 100644 --- a/stdlib/lib2to3/fixes/fix_filter.pyi +++ b/stdlib/lib2to3/fixes/fix_filter.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixFilter(fixer_base.ConditionalFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] skip_on: ClassVar[Literal["future_builtins.filter"]] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_funcattrs.pyi b/stdlib/lib2to3/fixes/fix_funcattrs.pyi index 13e63c80c394..59919446ffdd 100644 --- a/stdlib/lib2to3/fixes/fix_funcattrs.pyi +++ b/stdlib/lib2to3/fixes/fix_funcattrs.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixFuncattrs(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_future.pyi b/stdlib/lib2to3/fixes/fix_future.pyi index fa83e61bbb6d..8eb5ca35dcc3 100644 --- a/stdlib/lib2to3/fixes/fix_future.pyi +++ b/stdlib/lib2to3/fixes/fix_future.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixFuture(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_getcwdu.pyi b/stdlib/lib2to3/fixes/fix_getcwdu.pyi index 4c2e45cb7fa6..d18a38f69be0 100644 --- a/stdlib/lib2to3/fixes/fix_getcwdu.pyi +++ b/stdlib/lib2to3/fixes/fix_getcwdu.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixGetcwdu(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_has_key.pyi b/stdlib/lib2to3/fixes/fix_has_key.pyi index b2d76e270829..1e6b58dd3512 100644 --- a/stdlib/lib2to3/fixes/fix_has_key.pyi +++ b/stdlib/lib2to3/fixes/fix_has_key.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixHasKey(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_idioms.pyi b/stdlib/lib2to3/fixes/fix_idioms.pyi index 8914dd243f3b..8f02252f7bb9 100644 --- a/stdlib/lib2to3/fixes/fix_idioms.pyi +++ b/stdlib/lib2to3/fixes/fix_idioms.pyi @@ -1,5 +1,5 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -8,7 +8,7 @@ TYPE: str class FixIdioms(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[False]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def match(self, node): ... def transform(self, node, results): ... def transform_isinstance(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_import.pyi b/stdlib/lib2to3/fixes/fix_import.pyi index 5e97af4a8362..c18b8099c3fb 100644 --- a/stdlib/lib2to3/fixes/fix_import.pyi +++ b/stdlib/lib2to3/fixes/fix_import.pyi @@ -2,7 +2,7 @@ from _typeshed import StrPath from collections.abc import Generator from lib2to3.pytree import Node from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -10,7 +10,7 @@ def traverse_imports(names) -> Generator[str, None, None]: ... class FixImport(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] skip: bool def start_tree(self, tree: Node, name: StrPath) -> None: ... def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_input.pyi b/stdlib/lib2to3/fixes/fix_input.pyi index d6ad6ce49340..df52f8d77427 100644 --- a/stdlib/lib2to3/fixes/fix_input.pyi +++ b/stdlib/lib2to3/fixes/fix_input.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -8,5 +8,5 @@ context: Incomplete class FixInput(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_intern.pyi b/stdlib/lib2to3/fixes/fix_intern.pyi index b15b9f5c70db..f4e71b6da5f2 100644 --- a/stdlib/lib2to3/fixes/fix_intern.pyi +++ b/stdlib/lib2to3/fixes/fix_intern.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +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[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_isinstance.pyi b/stdlib/lib2to3/fixes/fix_isinstance.pyi index 2cea351b76ce..e776ea043714 100644 --- a/stdlib/lib2to3/fixes/fix_isinstance.pyi +++ b/stdlib/lib2to3/fixes/fix_isinstance.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixIsinstance(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_itertools.pyi b/stdlib/lib2to3/fixes/fix_itertools.pyi index 3ef79eaf9ca5..a19f7b5e8a00 100644 --- a/stdlib/lib2to3/fixes/fix_itertools.pyi +++ b/stdlib/lib2to3/fixes/fix_itertools.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixItertools(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] it_funcs: str - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_itertools_imports.pyi b/stdlib/lib2to3/fixes/fix_itertools_imports.pyi index 22d579e111cf..1ea0b506aaa2 100644 --- a/stdlib/lib2to3/fixes/fix_itertools_imports.pyi +++ b/stdlib/lib2to3/fixes/fix_itertools_imports.pyi @@ -1,8 +1,8 @@ from lib2to3 import fixer_base from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal class FixItertoolsImports(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_map.pyi b/stdlib/lib2to3/fixes/fix_map.pyi index b476f1277900..66e311cba8a8 100644 --- a/stdlib/lib2to3/fixes/fix_map.pyi +++ b/stdlib/lib2to3/fixes/fix_map.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixMap(fixer_base.ConditionalFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] skip_on: ClassVar[Literal["future_builtins.map"]] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_metaclass.pyi b/stdlib/lib2to3/fixes/fix_metaclass.pyi index cf2ceb5123c6..44626b47072d 100644 --- a/stdlib/lib2to3/fixes/fix_metaclass.pyi +++ b/stdlib/lib2to3/fixes/fix_metaclass.pyi @@ -1,6 +1,6 @@ from collections.abc import Generator from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base from ..pytree import Base @@ -14,5 +14,5 @@ def fixup_indent(suite) -> None: ... class FixMetaclass(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_methodattrs.pyi b/stdlib/lib2to3/fixes/fix_methodattrs.pyi index e3a57f97f08e..9bda7992dc8b 100644 --- a/stdlib/lib2to3/fixes/fix_methodattrs.pyi +++ b/stdlib/lib2to3/fixes/fix_methodattrs.pyi @@ -1,5 +1,5 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -7,5 +7,5 @@ MAP: dict[str, str] class FixMethodattrs(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_next.pyi b/stdlib/lib2to3/fixes/fix_next.pyi index 6ea7b33188e5..65dbb21f4c90 100644 --- a/stdlib/lib2to3/fixes/fix_next.pyi +++ b/stdlib/lib2to3/fixes/fix_next.pyi @@ -1,7 +1,7 @@ from _typeshed import StrPath from lib2to3.pytree import Node from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -9,7 +9,7 @@ bind_warning: str class FixNext(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] order: ClassVar[Literal["pre"]] shadowed_next: bool def start_tree(self, tree: Node, filename: StrPath) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_nonzero.pyi b/stdlib/lib2to3/fixes/fix_nonzero.pyi index 55e3d09b9854..adf268fdb8e2 100644 --- a/stdlib/lib2to3/fixes/fix_nonzero.pyi +++ b/stdlib/lib2to3/fixes/fix_nonzero.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixNonzero(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_operator.pyi b/stdlib/lib2to3/fixes/fix_operator.pyi index 9607cdc488ba..6da150a51c0c 100644 --- a/stdlib/lib2to3/fixes/fix_operator.pyi +++ b/stdlib/lib2to3/fixes/fix_operator.pyi @@ -1,6 +1,6 @@ from lib2to3 import fixer_base from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal def invocation(s): ... @@ -9,5 +9,5 @@ class FixOperator(fixer_base.BaseFix): order: ClassVar[Literal["pre"]] methods: str obj: str - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_paren.pyi b/stdlib/lib2to3/fixes/fix_paren.pyi index ae99e1334ccf..c730cdc5d0b2 100644 --- a/stdlib/lib2to3/fixes/fix_paren.pyi +++ b/stdlib/lib2to3/fixes/fix_paren.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixParen(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_print.pyi b/stdlib/lib2to3/fixes/fix_print.pyi index 3d53f4572e67..2261c9489299 100644 --- a/stdlib/lib2to3/fixes/fix_print.pyi +++ b/stdlib/lib2to3/fixes/fix_print.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -8,6 +8,6 @@ parend_expr: Incomplete class FixPrint(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... def add_kwarg(self, l_nodes, s_kwd, n_expr) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_raise.pyi b/stdlib/lib2to3/fixes/fix_raise.pyi index 4961110cbf57..756a05ea3ddd 100644 --- a/stdlib/lib2to3/fixes/fix_raise.pyi +++ b/stdlib/lib2to3/fixes/fix_raise.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixRaise(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_raw_input.pyi b/stdlib/lib2to3/fixes/fix_raw_input.pyi index 29184edb694f..61d6ad7676ef 100644 --- a/stdlib/lib2to3/fixes/fix_raw_input.pyi +++ b/stdlib/lib2to3/fixes/fix_raw_input.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixRawInput(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_reduce.pyi b/stdlib/lib2to3/fixes/fix_reduce.pyi index e974da7c62e9..4ea07fdde00b 100644 --- a/stdlib/lib2to3/fixes/fix_reduce.pyi +++ b/stdlib/lib2to3/fixes/fix_reduce.pyi @@ -1,9 +1,9 @@ from lib2to3 import fixer_base from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal class FixReduce(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] order: ClassVar[Literal["pre"]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_reload.pyi b/stdlib/lib2to3/fixes/fix_reload.pyi index c9aa5b5cbfd7..8045ac507890 100644 --- a/stdlib/lib2to3/fixes/fix_reload.pyi +++ b/stdlib/lib2to3/fixes/fix_reload.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixReload(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] order: ClassVar[Literal["pre"]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_renames.pyi b/stdlib/lib2to3/fixes/fix_renames.pyi index 37c3706b7299..2ceca053e903 100644 --- a/stdlib/lib2to3/fixes/fix_renames.pyi +++ b/stdlib/lib2to3/fixes/fix_renames.pyi @@ -1,6 +1,6 @@ from collections.abc import Generator from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -13,6 +13,6 @@ def build_pattern() -> Generator[str, None, None]: ... class FixRenames(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] order: ClassVar[Literal["pre"]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def match(self, node): ... def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_repr.pyi b/stdlib/lib2to3/fixes/fix_repr.pyi index 6e03fc01f65b..6f3305846d18 100644 --- a/stdlib/lib2to3/fixes/fix_repr.pyi +++ b/stdlib/lib2to3/fixes/fix_repr.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixRepr(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_set_literal.pyi b/stdlib/lib2to3/fixes/fix_set_literal.pyi index f946ac9c5a5d..dd18413d6d5a 100644 --- a/stdlib/lib2to3/fixes/fix_set_literal.pyi +++ b/stdlib/lib2to3/fixes/fix_set_literal.pyi @@ -1,8 +1,8 @@ from lib2to3 import fixer_base from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal class FixSetLiteral(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_standarderror.pyi b/stdlib/lib2to3/fixes/fix_standarderror.pyi index 5f81b4fc78f4..fd23af5a711e 100644 --- a/stdlib/lib2to3/fixes/fix_standarderror.pyi +++ b/stdlib/lib2to3/fixes/fix_standarderror.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixStandarderror(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_sys_exc.pyi b/stdlib/lib2to3/fixes/fix_sys_exc.pyi index 807ee1f1a204..3dbcd38c4b26 100644 --- a/stdlib/lib2to3/fixes/fix_sys_exc.pyi +++ b/stdlib/lib2to3/fixes/fix_sys_exc.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixSysExc(fixer_base.BaseFix): exc_info: ClassVar[list[str]] BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_throw.pyi b/stdlib/lib2to3/fixes/fix_throw.pyi index a20d5c21a25b..50e37d44a58b 100644 --- a/stdlib/lib2to3/fixes/fix_throw.pyi +++ b/stdlib/lib2to3/fixes/fix_throw.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixThrow(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_tuple_params.pyi b/stdlib/lib2to3/fixes/fix_tuple_params.pyi index 33883f82f504..48eadf75341c 100644 --- a/stdlib/lib2to3/fixes/fix_tuple_params.pyi +++ b/stdlib/lib2to3/fixes/fix_tuple_params.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base @@ -8,7 +8,7 @@ def is_docstring(stmt): ... class FixTupleParams(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... def transform_lambda(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_types.pyi b/stdlib/lib2to3/fixes/fix_types.pyi index 0744ac42a20d..6ac1344b1e6c 100644 --- a/stdlib/lib2to3/fixes/fix_types.pyi +++ b/stdlib/lib2to3/fixes/fix_types.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixTypes(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/fixes/fix_ws_comma.pyi b/stdlib/lib2to3/fixes/fix_ws_comma.pyi index 3d4a911460f2..6231d90c65f1 100644 --- a/stdlib/lib2to3/fixes/fix_ws_comma.pyi +++ b/stdlib/lib2to3/fixes/fix_ws_comma.pyi @@ -1,12 +1,12 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base from ..pytree import Leaf class FixWsComma(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[False]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] COMMA: Leaf COLON: Leaf SEPS: tuple[Leaf, Leaf] diff --git a/stdlib/lib2to3/fixes/fix_xrange.pyi b/stdlib/lib2to3/fixes/fix_xrange.pyi index afe3be2869dc..50985e5576c2 100644 --- a/stdlib/lib2to3/fixes/fix_xrange.pyi +++ b/stdlib/lib2to3/fixes/fix_xrange.pyi @@ -1,21 +1,21 @@ from _typeshed import Incomplete, StrPath from lib2to3.pytree import Node from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixXrange(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] transformed_xranges: set[Incomplete] | None def start_tree(self, tree: Node, filename: StrPath) -> None: ... def finish_tree(self, tree: Node, filename: StrPath) -> None: ... def transform(self, node, results): ... def transform_xrange(self, node, results) -> None: ... def transform_range(self, node, results): ... - P1: ClassVar[LiteralString] + P1: ClassVar[str] p1: ClassVar[Incomplete] - P2: ClassVar[LiteralString] + P2: ClassVar[str] p2: ClassVar[Incomplete] def in_special_context(self, node): ... diff --git a/stdlib/lib2to3/fixes/fix_xreadlines.pyi b/stdlib/lib2to3/fixes/fix_xreadlines.pyi index 3240cfa0041a..39757155e5d9 100644 --- a/stdlib/lib2to3/fixes/fix_xreadlines.pyi +++ b/stdlib/lib2to3/fixes/fix_xreadlines.pyi @@ -1,9 +1,9 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixXreadlines(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] def transform(self, node, results) -> None: ... diff --git a/stdlib/lib2to3/fixes/fix_zip.pyi b/stdlib/lib2to3/fixes/fix_zip.pyi index 0c30242c23d9..0c70717aa2ac 100644 --- a/stdlib/lib2to3/fixes/fix_zip.pyi +++ b/stdlib/lib2to3/fixes/fix_zip.pyi @@ -1,10 +1,10 @@ from typing import ClassVar -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from .. import fixer_base class FixZip(fixer_base.ConditionalFix): BM_compatible: ClassVar[Literal[True]] - PATTERN: ClassVar[LiteralString] + PATTERN: ClassVar[str] skip_on: ClassVar[Literal["future_builtins.zip"]] def transform(self, node, results): ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 2cb8edb7dfd7..d14446f38565 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -13,7 +13,7 @@ _RawNode: TypeAlias = tuple[int, str, _Context, list[_NL] | None] HUGE: Final = 0x7FFFFFFF -def type_repr(type_num: int) -> str: ... +def type_repr(type_num: int) -> str | int: ... class Base: type: int From 0755c04e631302ed3b884806fde9cfa072aef441 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 27 Apr 2023 23:43:39 -0400 Subject: [PATCH 5/6] Use relative imports --- stdlib/lib2to3/btm_matcher.pyi | 5 +++-- stdlib/lib2to3/fixes/fix_except.pyi | 2 +- stdlib/lib2to3/fixes/fix_exitfunc.pyi | 3 ++- stdlib/lib2to3/fixes/fix_import.pyi | 2 +- stdlib/lib2to3/fixes/fix_imports.pyi | 2 +- stdlib/lib2to3/fixes/fix_next.pyi | 2 +- stdlib/lib2to3/fixes/fix_unicode.pyi | 2 +- stdlib/lib2to3/fixes/fix_urllib.pyi | 3 ++- stdlib/lib2to3/fixes/fix_xrange.pyi | 2 +- stdlib/lib2to3/pgen2/__init__.pyi | 5 +++-- stdlib/lib2to3/pgen2/driver.pyi | 7 ++++--- stdlib/lib2to3/pgen2/parse.pyi | 7 ++++--- stdlib/lib2to3/pgen2/pgen.pyi | 5 +++-- stdlib/lib2to3/pgen2/tokenize.pyi | 3 ++- stdlib/lib2to3/pygram.pyi | 3 ++- stdlib/lib2to3/refactor.pyi | 4 ++-- 16 files changed, 33 insertions(+), 24 deletions(-) diff --git a/stdlib/lib2to3/btm_matcher.pyi b/stdlib/lib2to3/btm_matcher.pyi index e7bf8f78125c..2bcf272e70bb 100644 --- a/stdlib/lib2to3/btm_matcher.pyi +++ b/stdlib/lib2to3/btm_matcher.pyi @@ -1,10 +1,11 @@ from _typeshed import Incomplete, SupportsGetItem from collections import defaultdict from collections.abc import Iterable -from lib2to3.fixer_base import BaseFix -from lib2to3.pytree import Leaf, Node from typing import TypeVar +from .fixer_base import BaseFix +from .pytree import Leaf, Node + _T = TypeVar("_T") class BMNode: diff --git a/stdlib/lib2to3/fixes/fix_except.pyi b/stdlib/lib2to3/fixes/fix_except.pyi index ca37de03bbca..55c9d0eaf85f 100644 --- a/stdlib/lib2to3/fixes/fix_except.pyi +++ b/stdlib/lib2to3/fixes/fix_except.pyi @@ -1,9 +1,9 @@ from collections.abc import Generator, Iterable -from lib2to3.pytree import Base from typing import ClassVar, TypeVar from typing_extensions import Literal from .. import fixer_base +from .pytree import Base _N = TypeVar("_N", bound=Base) diff --git a/stdlib/lib2to3/fixes/fix_exitfunc.pyi b/stdlib/lib2to3/fixes/fix_exitfunc.pyi index 9c5434dad079..0fcee7b5a28d 100644 --- a/stdlib/lib2to3/fixes/fix_exitfunc.pyi +++ b/stdlib/lib2to3/fixes/fix_exitfunc.pyi @@ -1,9 +1,10 @@ from _typeshed import Incomplete, StrPath from lib2to3 import fixer_base -from lib2to3.pytree import Node 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] diff --git a/stdlib/lib2to3/fixes/fix_import.pyi b/stdlib/lib2to3/fixes/fix_import.pyi index c18b8099c3fb..caff7de9111f 100644 --- a/stdlib/lib2to3/fixes/fix_import.pyi +++ b/stdlib/lib2to3/fixes/fix_import.pyi @@ -1,10 +1,10 @@ from _typeshed import StrPath from collections.abc import Generator -from lib2to3.pytree import Node 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]: ... diff --git a/stdlib/lib2to3/fixes/fix_imports.pyi b/stdlib/lib2to3/fixes/fix_imports.pyi index 2fa1f94a50d4..d731d9e91498 100644 --- a/stdlib/lib2to3/fixes/fix_imports.pyi +++ b/stdlib/lib2to3/fixes/fix_imports.pyi @@ -1,10 +1,10 @@ from _typeshed import StrPath from collections.abc import Generator -from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal from .. import fixer_base +from .pytree import Node MAPPING: dict[str, str] diff --git a/stdlib/lib2to3/fixes/fix_next.pyi b/stdlib/lib2to3/fixes/fix_next.pyi index 65dbb21f4c90..9d30de438e45 100644 --- a/stdlib/lib2to3/fixes/fix_next.pyi +++ b/stdlib/lib2to3/fixes/fix_next.pyi @@ -1,9 +1,9 @@ from _typeshed import StrPath -from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal from .. import fixer_base +from .pytree import Node bind_warning: str diff --git a/stdlib/lib2to3/fixes/fix_unicode.pyi b/stdlib/lib2to3/fixes/fix_unicode.pyi index 86d787ddff25..824dfed999f3 100644 --- a/stdlib/lib2to3/fixes/fix_unicode.pyi +++ b/stdlib/lib2to3/fixes/fix_unicode.pyi @@ -1,9 +1,9 @@ from _typeshed import StrPath -from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal from .. import fixer_base +from .pytree import Node class FixUnicode(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/stdlib/lib2to3/fixes/fix_urllib.pyi b/stdlib/lib2to3/fixes/fix_urllib.pyi index 24b38213c01f..038a1db63ae7 100644 --- a/stdlib/lib2to3/fixes/fix_urllib.pyi +++ b/stdlib/lib2to3/fixes/fix_urllib.pyi @@ -1,7 +1,8 @@ from collections.abc import Generator -from lib2to3.fixes.fix_imports import FixImports from typing_extensions import Literal +from .fixes.fix_imports import FixImports + MAPPING: dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]] def build_pattern() -> Generator[str, None, None]: ... diff --git a/stdlib/lib2to3/fixes/fix_xrange.pyi b/stdlib/lib2to3/fixes/fix_xrange.pyi index 50985e5576c2..4cd073fc304c 100644 --- a/stdlib/lib2to3/fixes/fix_xrange.pyi +++ b/stdlib/lib2to3/fixes/fix_xrange.pyi @@ -1,9 +1,9 @@ from _typeshed import Incomplete, StrPath -from lib2to3.pytree import Node from typing import ClassVar from typing_extensions import Literal from .. import fixer_base +from .pytree import Node class FixXrange(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/stdlib/lib2to3/pgen2/__init__.pyi b/stdlib/lib2to3/pgen2/__init__.pyi index acc1cc429be9..8a75cbcbfbbd 100644 --- a/stdlib/lib2to3/pgen2/__init__.pyi +++ b/stdlib/lib2to3/pgen2/__init__.pyi @@ -1,8 +1,9 @@ from collections.abc import Callable -from lib2to3.pgen2.grammar import Grammar -from lib2to3.pytree import _RawNode from typing import Any from typing_extensions import TypeAlias +from .pgen2.grammar import Grammar +from .pytree import _RawNode + # This is imported in several lib2to3/pgen2 submodules _Convert: TypeAlias = Callable[[Grammar, _RawNode], Any] # noqa: Y047 diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index ee6f880b736a..4e12f8270a5e 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -1,11 +1,12 @@ from _typeshed import StrPath from collections.abc import Iterable -from lib2to3.pgen2 import _Convert -from lib2to3.pgen2.grammar import Grammar -from lib2to3.pytree import _NL from logging import Logger from typing import IO +from .pgen2 import _Convert +from .pgen2.grammar import Grammar +from .pytree import _NL + __all__ = ["Driver", "load_grammar"] class Driver: diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index 410cca737f69..cd455823051b 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,10 +1,11 @@ from _typeshed import Incomplete from collections.abc import Sequence -from lib2to3.pgen2 import _Convert -from lib2to3.pgen2.grammar import _DFAS, Grammar -from lib2to3.pytree import _NL, _RawNode from typing_extensions import TypeAlias +from .pgen2 import _Convert +from .pgen2.grammar import _DFAS, Grammar +from .pytree import _NL, _RawNode + _Context: TypeAlias = Sequence[Incomplete] class ParseError(Exception): diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index 9afa91e17220..7e74d15c9ed5 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,9 +1,10 @@ from _typeshed import Incomplete, StrPath from collections.abc import Iterable, Iterator -from lib2to3.pgen2 import grammar -from lib2to3.pgen2.tokenize import _TokenInfo from typing import IO, NoReturn, overload +from .pgen2 import grammar +from .pgen2.tokenize import _TokenInfo + class PgenGrammar(grammar.Grammar): ... class ParserGenerator: diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index 2a9c3fbba821..3a69805a076d 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,7 +1,8 @@ from collections.abc import Callable, Iterable, Iterator -from lib2to3.pgen2.token import * from typing_extensions import TypeAlias +from .pgen2.token import * + __all__ = [ "AMPER", "AMPEREQUAL", diff --git a/stdlib/lib2to3/pygram.pyi b/stdlib/lib2to3/pygram.pyi index 00fdbd1a124e..2d1e90e79927 100644 --- a/stdlib/lib2to3/pygram.pyi +++ b/stdlib/lib2to3/pygram.pyi @@ -1,5 +1,6 @@ import sys -from lib2to3.pgen2.grammar import Grammar + +from .pgen2.grammar import Grammar class Symbols: def __init__(self, grammar: Grammar) -> None: ... diff --git a/stdlib/lib2to3/refactor.pyi b/stdlib/lib2to3/refactor.pyi index 9ba2e407d82f..d750d9c4a6cf 100644 --- a/stdlib/lib2to3/refactor.pyi +++ b/stdlib/lib2to3/refactor.pyi @@ -1,14 +1,14 @@ from _typeshed import FileDescriptorOrPath, StrPath, SupportsGetItem from collections.abc import Container, Generator, Iterable, Mapping -from lib2to3.btm_matcher import BottomMatcher -from lib2to3.pgen2.driver import Driver from logging import Logger, _ExcInfoType from multiprocessing import JoinableQueue from multiprocessing.synchronize import Lock from typing import Any, ClassVar, NoReturn, overload from typing_extensions import Final +from .btm_matcher import BottomMatcher from .fixer_base import BaseFix +from .pgen2.driver import Driver from .pgen2.grammar import Grammar from .pytree import Node From a69e2519cc6ca93aeb099f8559eb02cba4c7a080 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 27 Apr 2023 23:48:09 -0400 Subject: [PATCH 6/6] Run fixes --- stdlib/lib2to3/btm_matcher.pyi | 3 --- stdlib/lib2to3/fixes/fix_except.pyi | 2 +- stdlib/lib2to3/fixes/fix_exitfunc.pyi | 2 +- stdlib/lib2to3/fixes/fix_import.pyi | 2 +- stdlib/lib2to3/fixes/fix_imports.pyi | 2 +- stdlib/lib2to3/fixes/fix_next.pyi | 2 +- stdlib/lib2to3/fixes/fix_unicode.pyi | 2 +- stdlib/lib2to3/fixes/fix_urllib.pyi | 2 +- stdlib/lib2to3/fixes/fix_xrange.pyi | 2 +- stdlib/lib2to3/pgen2/__init__.pyi | 4 ++-- stdlib/lib2to3/pgen2/driver.pyi | 6 +++--- stdlib/lib2to3/pgen2/parse.pyi | 6 +++--- stdlib/lib2to3/pgen2/pgen.pyi | 4 ++-- stdlib/lib2to3/pgen2/tokenize.pyi | 2 +- 14 files changed, 19 insertions(+), 22 deletions(-) diff --git a/stdlib/lib2to3/btm_matcher.pyi b/stdlib/lib2to3/btm_matcher.pyi index 2bcf272e70bb..4c87b664eb20 100644 --- a/stdlib/lib2to3/btm_matcher.pyi +++ b/stdlib/lib2to3/btm_matcher.pyi @@ -1,13 +1,10 @@ from _typeshed import Incomplete, SupportsGetItem from collections import defaultdict from collections.abc import Iterable -from typing import TypeVar from .fixer_base import BaseFix from .pytree import Leaf, Node -_T = TypeVar("_T") - class BMNode: count: Incomplete transition_table: Incomplete diff --git a/stdlib/lib2to3/fixes/fix_except.pyi b/stdlib/lib2to3/fixes/fix_except.pyi index 55c9d0eaf85f..b87aacd342e9 100644 --- a/stdlib/lib2to3/fixes/fix_except.pyi +++ b/stdlib/lib2to3/fixes/fix_except.pyi @@ -3,7 +3,7 @@ from typing import ClassVar, TypeVar from typing_extensions import Literal from .. import fixer_base -from .pytree import Base +from ..pytree import Base _N = TypeVar("_N", bound=Base) diff --git a/stdlib/lib2to3/fixes/fix_exitfunc.pyi b/stdlib/lib2to3/fixes/fix_exitfunc.pyi index 0fcee7b5a28d..10341d7985a8 100644 --- a/stdlib/lib2to3/fixes/fix_exitfunc.pyi +++ b/stdlib/lib2to3/fixes/fix_exitfunc.pyi @@ -3,7 +3,7 @@ from lib2to3 import fixer_base from typing import ClassVar from typing_extensions import Literal -from .pytree import Node +from ..pytree import Node class FixExitfunc(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/stdlib/lib2to3/fixes/fix_import.pyi b/stdlib/lib2to3/fixes/fix_import.pyi index caff7de9111f..436e7f1915b2 100644 --- a/stdlib/lib2to3/fixes/fix_import.pyi +++ b/stdlib/lib2to3/fixes/fix_import.pyi @@ -4,7 +4,7 @@ from typing import ClassVar from typing_extensions import Literal from .. import fixer_base -from .pytree import Node +from ..pytree import Node def traverse_imports(names) -> Generator[str, None, None]: ... diff --git a/stdlib/lib2to3/fixes/fix_imports.pyi b/stdlib/lib2to3/fixes/fix_imports.pyi index d731d9e91498..6c7a2605e9b4 100644 --- a/stdlib/lib2to3/fixes/fix_imports.pyi +++ b/stdlib/lib2to3/fixes/fix_imports.pyi @@ -4,7 +4,7 @@ from typing import ClassVar from typing_extensions import Literal from .. import fixer_base -from .pytree import Node +from ..pytree import Node MAPPING: dict[str, str] diff --git a/stdlib/lib2to3/fixes/fix_next.pyi b/stdlib/lib2to3/fixes/fix_next.pyi index 9d30de438e45..a5757d65064a 100644 --- a/stdlib/lib2to3/fixes/fix_next.pyi +++ b/stdlib/lib2to3/fixes/fix_next.pyi @@ -3,7 +3,7 @@ from typing import ClassVar from typing_extensions import Literal from .. import fixer_base -from .pytree import Node +from ..pytree import Node bind_warning: str diff --git a/stdlib/lib2to3/fixes/fix_unicode.pyi b/stdlib/lib2to3/fixes/fix_unicode.pyi index 824dfed999f3..af63d1865f2d 100644 --- a/stdlib/lib2to3/fixes/fix_unicode.pyi +++ b/stdlib/lib2to3/fixes/fix_unicode.pyi @@ -3,7 +3,7 @@ from typing import ClassVar from typing_extensions import Literal from .. import fixer_base -from .pytree import Node +from ..pytree import Node class FixUnicode(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/stdlib/lib2to3/fixes/fix_urllib.pyi b/stdlib/lib2to3/fixes/fix_urllib.pyi index 038a1db63ae7..a37e63b31101 100644 --- a/stdlib/lib2to3/fixes/fix_urllib.pyi +++ b/stdlib/lib2to3/fixes/fix_urllib.pyi @@ -1,7 +1,7 @@ from collections.abc import Generator from typing_extensions import Literal -from .fixes.fix_imports import FixImports +from .fix_imports import FixImports MAPPING: dict[str, list[tuple[Literal["urllib.request", "urllib.parse", "urllib.error"], list[str]]]] diff --git a/stdlib/lib2to3/fixes/fix_xrange.pyi b/stdlib/lib2to3/fixes/fix_xrange.pyi index 4cd073fc304c..89d300ef063a 100644 --- a/stdlib/lib2to3/fixes/fix_xrange.pyi +++ b/stdlib/lib2to3/fixes/fix_xrange.pyi @@ -3,7 +3,7 @@ from typing import ClassVar from typing_extensions import Literal from .. import fixer_base -from .pytree import Node +from ..pytree import Node class FixXrange(fixer_base.BaseFix): BM_compatible: ClassVar[Literal[True]] diff --git a/stdlib/lib2to3/pgen2/__init__.pyi b/stdlib/lib2to3/pgen2/__init__.pyi index 8a75cbcbfbbd..de8a874f434d 100644 --- a/stdlib/lib2to3/pgen2/__init__.pyi +++ b/stdlib/lib2to3/pgen2/__init__.pyi @@ -2,8 +2,8 @@ from collections.abc import Callable from typing import Any from typing_extensions import TypeAlias -from .pgen2.grammar import Grammar -from .pytree import _RawNode +from ..pytree import _RawNode +from .grammar import Grammar # This is imported in several lib2to3/pgen2 submodules _Convert: TypeAlias = Callable[[Grammar, _RawNode], Any] # noqa: Y047 diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index 4e12f8270a5e..dea13fb9d0f8 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -3,9 +3,9 @@ from collections.abc import Iterable from logging import Logger from typing import IO -from .pgen2 import _Convert -from .pgen2.grammar import Grammar -from .pytree import _NL +from ..pytree import _NL +from . import _Convert +from .grammar import Grammar __all__ = ["Driver", "load_grammar"] diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index cd455823051b..320c5f018d43 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -2,9 +2,9 @@ from _typeshed import Incomplete from collections.abc import Sequence from typing_extensions import TypeAlias -from .pgen2 import _Convert -from .pgen2.grammar import _DFAS, Grammar -from .pytree import _NL, _RawNode +from ..pytree import _NL, _RawNode +from . import _Convert +from .grammar import _DFAS, Grammar _Context: TypeAlias = Sequence[Incomplete] diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index 7e74d15c9ed5..6d9f776c61ae 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete, StrPath from collections.abc import Iterable, Iterator from typing import IO, NoReturn, overload -from .pgen2 import grammar -from .pgen2.tokenize import _TokenInfo +from . import grammar +from .tokenize import _TokenInfo class PgenGrammar(grammar.Grammar): ... diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index 3a69805a076d..af54de1b51d3 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Iterable, Iterator from typing_extensions import TypeAlias -from .pgen2.token import * +from .token import * __all__ = [ "AMPER",