Skip to content

Commit c821503

Browse files
authored
More LSP compatibility on arg names (#18363)
Got lost when #18356 was broken up
1 parent 4a0b331 commit c821503

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

mypy/plugin.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ def fail(self, msg: str, ctx: Context, *, code: ErrorCode | None = None) -> None
170170
raise NotImplementedError
171171

172172
@abstractmethod
173-
def named_type(self, name: str, args: list[Type]) -> Instance:
173+
def named_type(self, fullname: str, args: list[Type], /) -> Instance:
174174
"""Construct an instance of a builtin type with given name."""
175175
raise NotImplementedError
176176

177177
@abstractmethod
178-
def analyze_type(self, typ: Type) -> Type:
178+
def analyze_type(self, typ: Type, /) -> Type:
179179
"""Analyze an unbound type using the default mypy logic."""
180180
raise NotImplementedError
181181

@@ -319,7 +319,8 @@ def fail(
319319
@abstractmethod
320320
def anal_type(
321321
self,
322-
t: Type,
322+
typ: Type,
323+
/,
323324
*,
324325
tvar_scope: TypeVarLikeScope | None = None,
325326
allow_tuple_literal: bool = False,
@@ -340,15 +341,15 @@ def class_type(self, self_type: Type) -> Type:
340341
raise NotImplementedError
341342

342343
@abstractmethod
343-
def lookup_fully_qualified(self, name: str) -> SymbolTableNode:
344+
def lookup_fully_qualified(self, fullname: str, /) -> SymbolTableNode:
344345
"""Lookup a symbol by its fully qualified name.
345346
346347
Raise an error if not found.
347348
"""
348349
raise NotImplementedError
349350

350351
@abstractmethod
351-
def lookup_fully_qualified_or_none(self, name: str) -> SymbolTableNode | None:
352+
def lookup_fully_qualified_or_none(self, fullname: str, /) -> SymbolTableNode | None:
352353
"""Lookup a symbol by its fully qualified name.
353354
354355
Return None if not found.
@@ -384,12 +385,12 @@ def add_plugin_dependency(self, trigger: str, target: str | None = None) -> None
384385
raise NotImplementedError
385386

386387
@abstractmethod
387-
def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> Any:
388+
def add_symbol_table_node(self, name: str, symbol: SymbolTableNode) -> Any:
388389
"""Add node to global symbol table (or to nearest class if there is one)."""
389390
raise NotImplementedError
390391

391392
@abstractmethod
392-
def qualified_name(self, n: str) -> str:
393+
def qualified_name(self, name: str) -> str:
393394
"""Make qualified name using current module and enclosing class (if any)."""
394395
raise NotImplementedError
395396

mypy/semanal_shared.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ def lookup_qualified(
7676
raise NotImplementedError
7777

7878
@abstractmethod
79-
def lookup_fully_qualified(self, name: str) -> SymbolTableNode:
79+
def lookup_fully_qualified(self, fullname: str, /) -> SymbolTableNode:
8080
raise NotImplementedError
8181

8282
@abstractmethod
83-
def lookup_fully_qualified_or_none(self, name: str) -> SymbolTableNode | None:
83+
def lookup_fully_qualified_or_none(self, fullname: str, /) -> SymbolTableNode | None:
8484
raise NotImplementedError
8585

8686
@abstractmethod
@@ -176,7 +176,8 @@ def accept(self, node: Node) -> None:
176176
@abstractmethod
177177
def anal_type(
178178
self,
179-
t: Type,
179+
typ: Type,
180+
/,
180181
*,
181182
tvar_scope: TypeVarLikeScope | None = None,
182183
allow_tuple_literal: bool = False,
@@ -198,11 +199,11 @@ def basic_new_typeinfo(self, name: str, basetype_or_fallback: Instance, line: in
198199
raise NotImplementedError
199200

200201
@abstractmethod
201-
def schedule_patch(self, priority: int, fn: Callable[[], None]) -> None:
202+
def schedule_patch(self, priority: int, patch: Callable[[], None]) -> None:
202203
raise NotImplementedError
203204

204205
@abstractmethod
205-
def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> bool:
206+
def add_symbol_table_node(self, name: str, symbol: SymbolTableNode) -> bool:
206207
"""Add node to the current symbol table."""
207208
raise NotImplementedError
208209

@@ -242,7 +243,7 @@ def parse_bool(self, expr: Expression) -> bool | None:
242243
raise NotImplementedError
243244

244245
@abstractmethod
245-
def qualified_name(self, n: str) -> str:
246+
def qualified_name(self, name: str) -> str:
246247
raise NotImplementedError
247248

248249
@property
@@ -309,7 +310,7 @@ def calculate_tuple_fallback(typ: TupleType) -> None:
309310

310311

311312
class _NamedTypeCallback(Protocol):
312-
def __call__(self, fully_qualified_name: str, args: list[Type] | None = None) -> Instance: ...
313+
def __call__(self, fullname: str, args: list[Type] | None = None) -> Instance: ...
313314

314315

315316
def paramspec_args(

mypy/typeanal.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ def lookup_qualified(
288288
) -> SymbolTableNode | None:
289289
return self.api.lookup_qualified(name, ctx, suppress_errors)
290290

291-
def lookup_fully_qualified(self, name: str) -> SymbolTableNode:
292-
return self.api.lookup_fully_qualified(name)
291+
def lookup_fully_qualified(self, fullname: str) -> SymbolTableNode:
292+
return self.api.lookup_fully_qualified(fullname)
293293

294294
def visit_unbound_type(self, t: UnboundType, defining_literal: bool = False) -> Type:
295295
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]
17621762
self.fail(f"Parameter {idx} of Literal[...] is invalid", ctx, code=codes.VALID_TYPE)
17631763
return None
17641764

1765-
def analyze_type(self, t: Type) -> Type:
1766-
return t.accept(self)
1765+
def analyze_type(self, typ: Type) -> Type:
1766+
return typ.accept(self)
17671767

17681768
def fail(self, msg: str, ctx: Context, *, code: ErrorCode | None = None) -> None:
17691769
self.fail_func(msg, ctx, code=code)
@@ -1937,13 +1937,9 @@ def anal_var_defs(self, var_defs: Sequence[TypeVarLikeType]) -> list[TypeVarLike
19371937
return [self.anal_var_def(vd) for vd in var_defs]
19381938

19391939
def named_type(
1940-
self,
1941-
fully_qualified_name: str,
1942-
args: list[Type] | None = None,
1943-
line: int = -1,
1944-
column: int = -1,
1940+
self, fullname: str, args: list[Type] | None = None, line: int = -1, column: int = -1
19451941
) -> Instance:
1946-
node = self.lookup_fully_qualified(fully_qualified_name)
1942+
node = self.lookup_fully_qualified(fullname)
19471943
assert isinstance(node.node, TypeInfo)
19481944
any_type = AnyType(TypeOfAny.special_form)
19491945
if args is not None:

0 commit comments

Comments
 (0)