Skip to content

Commit 2b008eb

Browse files
hauntsaninjacdce8p
authored andcommitted
Ensure LSP on arg names
Pairs well with python#18355
1 parent adabb39 commit 2b008eb

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

mypy/plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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, n: str, /) -> str:
393394
"""Make qualified name using current module and enclosing class (if any)."""
394395
raise NotImplementedError
395396

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,7 @@ def analyze_namedtuple_classdef(
20902090
defn, self.is_stub_file, self.is_func_scope()
20912091
)
20922092
if is_named_tuple:
2093-
if info is None:
2093+
if info is None or any(has_placeholder(tv) for tv in tvar_defs):
20942094
self.mark_incomplete(defn.name, defn)
20952095
else:
20962096
self.prepare_class_def(defn, info, custom_names=True)

mypy/semanal_shared.py

Lines changed: 8 additions & 7 deletions
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, n: 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, name: str, args: list[Type] | None = None) -> Instance: ...
313314

314315

315316
def paramspec_args(

mypy/test/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,5 +816,5 @@ def setup(self) -> None:
816816
"""Setup fixtures (ad-hoc)"""
817817

818818
@abstractmethod
819-
def run_case(self, testcase: DataDrivenTestCase) -> None:
819+
def run_case(self, test_case: DataDrivenTestCase, /) -> None:
820820
raise NotImplementedError

mypy/typeanal.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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, name: 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(name)
19471943
assert isinstance(node.node, TypeInfo)
19481944
any_type = AnyType(TypeOfAny.special_form)
19491945
if args is not None:

0 commit comments

Comments
 (0)