Skip to content

Commit 7f10b71

Browse files
author
hauntsaninja
committed
typevarlikedef -> typevarliketype
1 parent 3415fca commit 7f10b71

8 files changed

+31
-31
lines changed

mypy/applytype.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from mypy.expandtype import expand_type
66
from mypy.types import (
77
Type, TypeVarId, TypeVarType, CallableType, AnyType, PartialType, get_proper_types,
8-
TypeVarLikeDef, ProperType
8+
TypeVarLikeType, ProperType
99
)
1010
from mypy.nodes import Context
1111

1212

1313
def get_target_type(
14-
tvar: TypeVarLikeDef,
14+
tvar: TypeVarLikeType,
1515
type: ProperType,
1616
callable: CallableType,
1717
report_incompatible_typevar_value: Callable[[CallableType, Type, str, Context], None],

mypy/checkmember.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from mypy.types import (
77
Type, Instance, AnyType, TupleType, TypedDictType, CallableType, FunctionLike,
8-
TypeVarLikeDef, Overloaded, TypeVarType, UnionType, PartialType, TypeOfAny, LiteralType,
8+
TypeVarLikeType, Overloaded, TypeVarType, UnionType, PartialType, TypeOfAny, LiteralType,
99
DeletedType, NoneType, TypeType, has_type_vars, get_proper_type, ProperType
1010
)
1111
from mypy.nodes import (
@@ -679,7 +679,7 @@ def analyze_class_attribute_access(itype: Instance,
679679
name: str,
680680
mx: MemberContext,
681681
override_info: Optional[TypeInfo] = None,
682-
original_vars: Optional[Sequence[TypeVarLikeDef]] = None
682+
original_vars: Optional[Sequence[TypeVarLikeType]] = None
683683
) -> Optional[Type]:
684684
"""Analyze access to an attribute on a class object.
685685
@@ -842,7 +842,7 @@ def analyze_enum_class_attribute_access(itype: Instance,
842842
def add_class_tvars(t: ProperType, isuper: Optional[Instance],
843843
is_classmethod: bool,
844844
original_type: Type,
845-
original_vars: Optional[Sequence[TypeVarLikeDef]] = None) -> Type:
845+
original_vars: Optional[Sequence[TypeVarLikeType]] = None) -> Type:
846846
"""Instantiate type variables during analyze_class_attribute_access,
847847
e.g T and Q in the following:
848848

mypy/messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ def [T <: int] f(self, x: int, y: T) -> None
18761876
else:
18771877
tvars.append(tvar.name)
18781878
else:
1879-
# For other TypeVarLikeDefs, just use the repr
1879+
# For other TypeVarLikeTypes, just use the repr
18801880
tvars.append(repr(tvar))
18811881
s = '[{}] {}'.format(', '.join(tvars), s)
18821882
return 'def {}'.format(s)

mypy/tvar_scope.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from typing import Optional, Dict, Union
2-
from mypy.types import TypeVarLikeDef, TypeVarType, ParamSpecDef
2+
from mypy.types import TypeVarLikeType, TypeVarType, ParamSpecDef
33
from mypy.nodes import ParamSpecExpr, TypeVarExpr, TypeVarLikeExpr, SymbolTableNode
44

55

66
class TypeVarLikeScope:
77
"""Scope that holds bindings for type variables and parameter specifications.
88
9-
Node fullname -> TypeVarLikeDef.
9+
Node fullname -> TypeVarLikeType.
1010
"""
1111

1212
def __init__(self,
@@ -21,7 +21,7 @@ def __init__(self,
2121
prohibited: Type variables that aren't strictly in scope exactly,
2222
but can't be bound because they're part of an outer class's scope.
2323
"""
24-
self.scope = {} # type: Dict[str, TypeVarLikeDef]
24+
self.scope = {} # type: Dict[str, TypeVarLikeType]
2525
self.parent = parent
2626
self.func_id = 0
2727
self.class_id = 0
@@ -55,7 +55,7 @@ def class_frame(self) -> 'TypeVarLikeScope':
5555
"""A new scope frame for binding a class. Prohibits *this* class's tvars"""
5656
return TypeVarLikeScope(self.get_function_scope(), True, self)
5757

58-
def bind_new(self, name: str, tvar_expr: TypeVarLikeExpr) -> TypeVarLikeDef:
58+
def bind_new(self, name: str, tvar_expr: TypeVarLikeExpr) -> TypeVarLikeType:
5959
if self.is_class_scope:
6060
self.class_id += 1
6161
i = self.class_id
@@ -72,7 +72,7 @@ def bind_new(self, name: str, tvar_expr: TypeVarLikeExpr) -> TypeVarLikeDef:
7272
variance=tvar_expr.variance,
7373
line=tvar_expr.line,
7474
column=tvar_expr.column
75-
) # type: TypeVarLikeDef
75+
) # type: TypeVarLikeType
7676
elif isinstance(tvar_expr, ParamSpecExpr):
7777
tvar_def = ParamSpecDef(
7878
name,
@@ -86,10 +86,10 @@ def bind_new(self, name: str, tvar_expr: TypeVarLikeExpr) -> TypeVarLikeDef:
8686
self.scope[tvar_expr.fullname] = tvar_def
8787
return tvar_def
8888

89-
def bind_existing(self, tvar_def: TypeVarLikeDef) -> None:
89+
def bind_existing(self, tvar_def: TypeVarLikeType) -> None:
9090
self.scope[tvar_def.fullname] = tvar_def
9191

92-
def get_binding(self, item: Union[str, SymbolTableNode]) -> Optional[TypeVarLikeDef]:
92+
def get_binding(self, item: Union[str, SymbolTableNode]) -> Optional[TypeVarLikeType]:
9393
fullname = item.fullname if isinstance(item, SymbolTableNode) else item
9494
assert fullname is not None
9595
if fullname in self.scope:

mypy/type_visitor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from mypy.types import (
2222
Type, AnyType, CallableType, Overloaded, TupleType, TypedDictType, LiteralType,
2323
RawExpressionType, Instance, NoneType, TypeType,
24-
UnionType, TypeVarType, PartialType, DeletedType, UninhabitedType, TypeVarLikeDef,
24+
UnionType, TypeVarType, PartialType, DeletedType, UninhabitedType, TypeVarLikeType,
2525
UnboundType, ErasedType, StarType, EllipsisType, TypeList, CallableArgument,
2626
PlaceholderType, TypeAliasType, get_proper_type
2727
)
@@ -221,7 +221,7 @@ def translate_types(self, types: Iterable[Type]) -> List[Type]:
221221
return [t.accept(self) for t in types]
222222

223223
def translate_variables(self,
224-
variables: Sequence[TypeVarLikeDef]) -> Sequence[TypeVarLikeDef]:
224+
variables: Sequence[TypeVarLikeType]) -> Sequence[TypeVarLikeType]:
225225
return variables
226226

227227
def visit_overloaded(self, t: Overloaded) -> Type:

mypy/typeanal.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
CallableType, NoneType, ErasedType, DeletedType, TypeList, SyntheticTypeVisitor,
1717
StarType, PartialType, EllipsisType, UninhabitedType, TypeType,
1818
CallableArgument, TypeQuery, union_items, TypeOfAny, LiteralType, RawExpressionType,
19-
PlaceholderType, Overloaded, get_proper_type, TypeAliasType, TypeVarLikeDef, ParamSpecDef
19+
PlaceholderType, Overloaded, get_proper_type, TypeAliasType, TypeVarLikeType, ParamSpecDef
2020
)
2121

2222
from mypy.nodes import (
@@ -917,7 +917,7 @@ def infer_type_variables(self,
917917

918918
def bind_function_type_variables(
919919
self, fun_type: CallableType, defn: Context
920-
) -> Sequence[TypeVarLikeDef]:
920+
) -> Sequence[TypeVarLikeType]:
921921
"""Find the type variables of the function type and bind them in our tvar_scope"""
922922
if fun_type.variables:
923923
for var in fun_type.variables:
@@ -931,7 +931,7 @@ def bind_function_type_variables(
931931
# Do not define a new type variable if already defined in scope.
932932
typevars = [(name, tvar) for name, tvar in typevars
933933
if not self.is_defined_type_var(name, defn)]
934-
defs = [] # type: List[TypeVarLikeDef]
934+
defs = [] # type: List[TypeVarLikeType]
935935
for name, tvar in typevars:
936936
if not self.tvar_scope.allow_binding(tvar.fullname):
937937
self.fail("Type variable '{}' is bound by an outer class".format(name), defn)
@@ -963,7 +963,7 @@ def anal_type(self, t: Type, nested: bool = True) -> Type:
963963
if nested:
964964
self.nesting_level -= 1
965965

966-
def anal_var_def(self, var_def: TypeVarLikeDef) -> TypeVarLikeDef:
966+
def anal_var_def(self, var_def: TypeVarLikeType) -> TypeVarLikeType:
967967
if isinstance(var_def, TypeVarType):
968968
return TypeVarType(
969969
var_def.name,
@@ -977,7 +977,7 @@ def anal_var_def(self, var_def: TypeVarLikeDef) -> TypeVarLikeDef:
977977
else:
978978
return var_def
979979

980-
def anal_var_defs(self, var_defs: Sequence[TypeVarLikeDef]) -> List[TypeVarLikeDef]:
980+
def anal_var_defs(self, var_defs: Sequence[TypeVarLikeType]) -> List[TypeVarLikeType]:
981981
return [self.anal_var_def(vd) for vd in var_defs]
982982

983983
def named_type_with_normalized_str(self, fully_qualified_name: str) -> Instance:

mypy/typeops.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys
1111

1212
from mypy.types import (
13-
TupleType, Instance, FunctionLike, Type, CallableType, TypeVarLikeDef, Overloaded,
13+
TupleType, Instance, FunctionLike, Type, CallableType, TypeVarLikeType, Overloaded,
1414
TypeVarType, UninhabitedType, FormalArgument, UnionType, NoneType, TypedDictType,
1515
AnyType, TypeOfAny, TypeType, ProperType, LiteralType, get_proper_type, get_proper_types,
1616
copy_type, TypeAliasType, TypeQuery
@@ -113,7 +113,7 @@ def class_callable(init_type: CallableType, info: TypeInfo, type_type: Instance,
113113
special_sig: Optional[str],
114114
is_new: bool, orig_self_type: Optional[Type] = None) -> CallableType:
115115
"""Create a type object type based on the signature of __init__."""
116-
variables = [] # type: List[TypeVarLikeDef]
116+
variables = [] # type: List[TypeVarLikeType]
117117
variables.extend(info.defn.type_vars)
118118
variables.extend(init_type.variables)
119119

@@ -228,7 +228,7 @@ class B(A): pass
228228
return cast(F, func)
229229
self_param_type = get_proper_type(func.arg_types[0])
230230

231-
variables = [] # type: Sequence[TypeVarLikeDef]
231+
variables = [] # type: Sequence[TypeVarLikeType]
232232
if func.variables and supported_self_type(self_param_type):
233233
if original_type is None:
234234
# TODO: type check method override (see #7861).
@@ -474,7 +474,7 @@ def true_or_false(t: Type) -> ProperType:
474474
return new_t
475475

476476

477-
def erase_def_to_union_or_bound(tdef: TypeVarLikeDef) -> Type:
477+
def erase_def_to_union_or_bound(tdef: TypeVarLikeType) -> Type:
478478
# TODO(shantanu): fix for ParamSpecDef
479479
assert isinstance(tdef, TypeVarType)
480480
if tdef.values:

mypy/types.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def is_meta_var(self) -> bool:
338338
return self.meta_level > 0
339339

340340

341-
class TypeVarLikeDef(ProperType):
341+
class TypeVarLikeType(ProperType):
342342
name = '' # Name (may be qualified)
343343
fullname = '' # Fully qualified name
344344
id = None # type: TypeVarId
@@ -357,11 +357,11 @@ def serialize(self) -> JsonDict:
357357
raise NotImplementedError
358358

359359
@classmethod
360-
def deserialize(cls, data: JsonDict) -> 'TypeVarLikeDef':
360+
def deserialize(cls, data: JsonDict) -> 'TypeVarLikeType':
361361
raise NotImplementedError
362362

363363

364-
class TypeVarType(TypeVarLikeDef):
364+
class TypeVarType(TypeVarLikeType):
365365
"""Definition of a single type variable."""
366366
values = None # type: List[Type] # Value restriction, empty list if no restriction
367367
upper_bound = None # type: Type
@@ -417,7 +417,7 @@ def deserialize(cls, data: JsonDict) -> 'TypeVarType':
417417
)
418418

419419

420-
class ParamSpecDef(TypeVarLikeDef):
420+
class ParamSpecDef(TypeVarLikeType):
421421
"""Definition of a single ParamSpec variable."""
422422

423423
def __repr__(self) -> str:
@@ -975,7 +975,7 @@ def __init__(self,
975975
fallback: Instance,
976976
name: Optional[str] = None,
977977
definition: Optional[SymbolNode] = None,
978-
variables: Optional[Sequence[TypeVarLikeDef]] = None,
978+
variables: Optional[Sequence[TypeVarLikeType]] = None,
979979
line: int = -1,
980980
column: int = -1,
981981
is_ellipsis_args: bool = False,
@@ -1029,7 +1029,7 @@ def copy_modified(self,
10291029
fallback: Bogus[Instance] = _dummy,
10301030
name: Bogus[Optional[str]] = _dummy,
10311031
definition: Bogus[SymbolNode] = _dummy,
1032-
variables: Bogus[Sequence[TypeVarLikeDef]] = _dummy,
1032+
variables: Bogus[Sequence[TypeVarLikeType]] = _dummy,
10331033
line: Bogus[int] = _dummy,
10341034
column: Bogus[int] = _dummy,
10351035
is_ellipsis_args: Bogus[bool] = _dummy,
@@ -2085,7 +2085,7 @@ def visit_callable_type(self, t: CallableType) -> str:
20852085
else:
20862086
vs.append(var.name)
20872087
else:
2088-
# For other TypeVarLikeDefs, just use the repr
2088+
# For other TypeVarLikeTypes, just use the repr
20892089
vs.append(repr(var))
20902090
s = '{} {}'.format('[{}]'.format(', '.join(vs)), s)
20912091

0 commit comments

Comments
 (0)