diff --git a/mypy/plugin.py b/mypy/plugin.py index fcbbc32f6237..39841d5b907a 100644 --- a/mypy/plugin.py +++ b/mypy/plugin.py @@ -170,12 +170,12 @@ def fail(self, msg: str, ctx: Context, *, code: ErrorCode | None = None) -> None raise NotImplementedError @abstractmethod - def named_type(self, name: str, args: list[Type]) -> Instance: + def named_type(self, fullname: str, args: list[Type], /) -> Instance: """Construct an instance of a builtin type with given name.""" raise NotImplementedError @abstractmethod - def analyze_type(self, typ: Type) -> Type: + def analyze_type(self, typ: Type, /) -> Type: """Analyze an unbound type using the default mypy logic.""" raise NotImplementedError @@ -319,7 +319,8 @@ def fail( @abstractmethod def anal_type( self, - t: Type, + typ: Type, + /, *, tvar_scope: TypeVarLikeScope | None = None, allow_tuple_literal: bool = False, @@ -340,7 +341,7 @@ def class_type(self, self_type: Type) -> Type: raise NotImplementedError @abstractmethod - def lookup_fully_qualified(self, name: str) -> SymbolTableNode: + def lookup_fully_qualified(self, fullname: str, /) -> SymbolTableNode: """Lookup a symbol by its fully qualified name. Raise an error if not found. @@ -348,7 +349,7 @@ def lookup_fully_qualified(self, name: str) -> SymbolTableNode: raise NotImplementedError @abstractmethod - def lookup_fully_qualified_or_none(self, name: str) -> SymbolTableNode | None: + def lookup_fully_qualified_or_none(self, fullname: str, /) -> SymbolTableNode | None: """Lookup a symbol by its fully qualified name. Return None if not found. @@ -384,12 +385,12 @@ def add_plugin_dependency(self, trigger: str, target: str | None = None) -> None raise NotImplementedError @abstractmethod - def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> Any: + def add_symbol_table_node(self, name: str, symbol: SymbolTableNode) -> Any: """Add node to global symbol table (or to nearest class if there is one).""" raise NotImplementedError @abstractmethod - def qualified_name(self, n: str) -> str: + def qualified_name(self, name: str) -> str: """Make qualified name using current module and enclosing class (if any).""" raise NotImplementedError diff --git a/mypy/semanal_shared.py b/mypy/semanal_shared.py index 941a16a7fd5d..b7d50e411016 100644 --- a/mypy/semanal_shared.py +++ b/mypy/semanal_shared.py @@ -76,11 +76,11 @@ def lookup_qualified( raise NotImplementedError @abstractmethod - def lookup_fully_qualified(self, name: str) -> SymbolTableNode: + def lookup_fully_qualified(self, fullname: str, /) -> SymbolTableNode: raise NotImplementedError @abstractmethod - def lookup_fully_qualified_or_none(self, name: str) -> SymbolTableNode | None: + def lookup_fully_qualified_or_none(self, fullname: str, /) -> SymbolTableNode | None: raise NotImplementedError @abstractmethod @@ -176,7 +176,8 @@ def accept(self, node: Node) -> None: @abstractmethod def anal_type( self, - t: Type, + typ: Type, + /, *, tvar_scope: TypeVarLikeScope | None = None, allow_tuple_literal: bool = False, @@ -198,11 +199,11 @@ def basic_new_typeinfo(self, name: str, basetype_or_fallback: Instance, line: in raise NotImplementedError @abstractmethod - def schedule_patch(self, priority: int, fn: Callable[[], None]) -> None: + def schedule_patch(self, priority: int, patch: Callable[[], None]) -> None: raise NotImplementedError @abstractmethod - def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> bool: + def add_symbol_table_node(self, name: str, symbol: SymbolTableNode) -> bool: """Add node to the current symbol table.""" raise NotImplementedError @@ -242,7 +243,7 @@ def parse_bool(self, expr: Expression) -> bool | None: raise NotImplementedError @abstractmethod - def qualified_name(self, n: str) -> str: + def qualified_name(self, name: str) -> str: raise NotImplementedError @property @@ -309,7 +310,7 @@ def calculate_tuple_fallback(typ: TupleType) -> None: class _NamedTypeCallback(Protocol): - def __call__(self, fully_qualified_name: str, args: list[Type] | None = None) -> Instance: ... + def __call__(self, fullname: str, args: list[Type] | None = None) -> Instance: ... def paramspec_args( diff --git a/mypy/typeanal.py b/mypy/typeanal.py index 751ed85ea6f3..d0dd8542fd91 100644 --- a/mypy/typeanal.py +++ b/mypy/typeanal.py @@ -288,8 +288,8 @@ def lookup_qualified( ) -> SymbolTableNode | None: return self.api.lookup_qualified(name, ctx, suppress_errors) - def lookup_fully_qualified(self, name: str) -> SymbolTableNode: - return self.api.lookup_fully_qualified(name) + def lookup_fully_qualified(self, fullname: str) -> SymbolTableNode: + return self.api.lookup_fully_qualified(fullname) def visit_unbound_type(self, t: UnboundType, defining_literal: bool = False) -> Type: typ = self.visit_unbound_type_nonoptional(t, defining_literal) @@ -1762,8 +1762,8 @@ def analyze_literal_param(self, idx: int, arg: Type, ctx: Context) -> list[Type] self.fail(f"Parameter {idx} of Literal[...] is invalid", ctx, code=codes.VALID_TYPE) return None - def analyze_type(self, t: Type) -> Type: - return t.accept(self) + def analyze_type(self, typ: Type) -> Type: + return typ.accept(self) def fail(self, msg: str, ctx: Context, *, code: ErrorCode | None = None) -> None: self.fail_func(msg, ctx, code=code) @@ -1937,13 +1937,9 @@ def anal_var_defs(self, var_defs: Sequence[TypeVarLikeType]) -> list[TypeVarLike return [self.anal_var_def(vd) for vd in var_defs] def named_type( - self, - fully_qualified_name: str, - args: list[Type] | None = None, - line: int = -1, - column: int = -1, + self, fullname: str, args: list[Type] | None = None, line: int = -1, column: int = -1 ) -> Instance: - node = self.lookup_fully_qualified(fully_qualified_name) + node = self.lookup_fully_qualified(fullname) assert isinstance(node.node, TypeInfo) any_type = AnyType(TypeOfAny.special_form) if args is not None: