Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
JelleZijlstra committed May 15, 2024
commit c05fdf6786e7fed3627078c97750eb3353353728
6 changes: 4 additions & 2 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2896,10 +2896,10 @@ def _collect_type_vars(types, typevar_types=None):
tvars = []

# required TypeVarLike cannot appear after TypeVarLike with default
# if it was a direct call to `Generic[]` or `Protocol[]`
default_encountered = False
# or after TypeVarTuple
type_var_tuple_encountered = False
# if it was a direct call to `Generic[]` or `Protocol[]`
enforce_default_ordering = _has_generic_or_protocol_as_origin()
for t in types:
if _is_unpacked_typevartuple(t):
Expand Down Expand Up @@ -2954,7 +2954,9 @@ def _collect_parameters(args):
elif hasattr(t, '__typing_subst__'):
if t not in parameters:
if enforce_default_ordering:
has_default = getattr(t, '__default__', NoDefault) is not NoDefault
has_default = (
getattr(t, '__default__', NoDefault) is not NoDefault
)

if type_var_tuple_encountered and has_default:
raise TypeError('Type parameter with a default'
Expand Down