Skip to content

Commit ade6128

Browse files
philippjfrhoxbro
andauthored
Apply suggestions from code review
Co-authored-by: Simon Høxbro Hansen <hoxbro@protonmail.com> Co-authored-by: Philipp Rudiger <prudiger@anaconda.com>
1 parent a298f27 commit ade6128

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

param/mypy_plugin.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
when it's an lvalue, return the Parameter's value type (the first type arg
1212
of Parameter[_T]) instead of the raw descriptor type.
1313
14-
Usage: add ``plugins = ["param._mypy_plugin"]`` to your mypy configuration.
14+
Usage: add ``plugins = ["param.mypy_plugin"]`` to your mypy configuration.
1515
"""
1616

1717
from __future__ import annotations
@@ -23,23 +23,19 @@
2323
from mypy.types import AnyType, Instance, Type, TypeOfAny, get_proper_type
2424

2525

26-
PARAMETER_BASE_FULLNAME = "param.parameterized.Parameter"
27-
PARAMETERIZED_FULLNAME = "param.parameterized.Parameterized"
28-
29-
3026
def _is_parameter_type(typ: Type) -> bool:
3127
proper = get_proper_type(typ)
3228
if not isinstance(proper, Instance):
3329
return False
3430
return any(
35-
base.fullname == PARAMETER_BASE_FULLNAME
31+
base.fullname == "param.parameterized.Parameter"
3632
for base in proper.type.mro
3733
)
3834

3935

4036
def _is_parameterized_class(info: TypeInfo) -> bool:
4137
return any(
42-
base.fullname == PARAMETERIZED_FULLNAME
38+
base.fullname == "param.parameterized.Parameterized"
4339
for base in info.mro
4440
)
4541

@@ -69,7 +65,7 @@ def _class_attribute_hook(ctx: AttributeContext) -> Type:
6965
return AnyType(TypeOfAny.special_form)
7066

7167

72-
class ParamPlugin(Plugin):
68+
class _ParamPlugin(Plugin):
7369
def get_class_attribute_hook(
7470
self, fullname: str
7571
) -> t.Callable[[AttributeContext], Type] | None:
@@ -96,4 +92,4 @@ def get_class_attribute_hook(
9692

9793

9894
def plugin(version: str) -> type[Plugin]:
99-
return ParamPlugin
95+
return _ParamPlugin

0 commit comments

Comments
 (0)