Skip to content

Commit 8622a58

Browse files
Merge branch 'master' into TypeVar-02-basic-validation
2 parents 0ea018e + a568f3a commit 8622a58

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

mypy/nodes.py

+2
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,8 @@ class TypeVarLikeExpr(SymbolNode, Expression):
24462446
# Upper bound: only subtypes of upper_bound are valid as values. By default
24472447
# this is 'object', meaning no restriction.
24482448
upper_bound: mypy.types.Type
2449+
# Default: used to resolve the TypeVar if the default is not explicitly given.
2450+
# By default this is 'AnyType(TypeOfAny.from_omitted_generics)'. See PEP 696.
24492451
default: mypy.types.Type
24502452
# Variance of the type variable. Invariant is the default.
24512453
# TypeVar(..., covariant=True) defines a covariant type variable.

mypy/semanal.py

+4
Original file line numberDiff line numberDiff line change
@@ -4283,6 +4283,8 @@ def process_paramspec_declaration(self, s: AssignmentStmt) -> bool:
42834283
s,
42844284
)
42854285

4286+
default: Type = AnyType(TypeOfAny.from_omitted_generics)
4287+
42864288
# PEP 612 reserves the right to define bound, covariant and contravariant arguments to
42874289
# ParamSpec in a later PEP. If and when that happens, we should do something
42884290
# on the lines of process_typevar_parameters
@@ -4347,6 +4349,8 @@ def process_typevartuple_declaration(self, s: AssignmentStmt) -> bool:
43474349
s,
43484350
)
43494351

4352+
default: Type = AnyType(TypeOfAny.from_omitted_generics)
4353+
43504354
if not self.incomplete_feature_enabled(TYPE_VAR_TUPLE, s):
43514355
return False
43524356

0 commit comments

Comments
 (0)