Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-104392: Remove _paramspec_tvars from typing #104393

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 6 additions & 13 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,7 @@ def Concatenate(self, parameters):
"ParamSpec variable or ellipsis.")
msg = "Concatenate[arg, ...]: each arg must be a type."
parameters = (*(_type_check(p, msg) for p in parameters[:-1]), parameters[-1])
return _ConcatenateGenericAlias(self, parameters,
_paramspec_tvars=True)
return _ConcatenateGenericAlias(self, parameters)


@_SpecialForm
Expand Down Expand Up @@ -1307,8 +1306,7 @@ def __getattr__(self, attr):
raise AttributeError(attr)

def __setattr__(self, attr, val):
if _is_dunder(attr) or attr in {'_name', '_inst', '_nparams',
'_paramspec_tvars'}:
if _is_dunder(attr) or attr in {'_name', '_inst', '_nparams'}:
super().__setattr__(attr, val)
else:
setattr(self.__origin__, attr, val)
Expand Down Expand Up @@ -1362,15 +1360,13 @@ class _GenericAlias(_BaseGenericAlias, _root=True):
# ClassVar[float]
# TypeVar[bool]

def __init__(self, origin, args, *, inst=True, name=None,
_paramspec_tvars=False):
def __init__(self, origin, args, *, inst=True, name=None):
super().__init__(origin, inst=inst, name=name)
if not isinstance(args, tuple):
args = (args,)
self.__args__ = tuple(... if a is _TypingEllipsis else
a for a in args)
self.__parameters__ = _collect_parameters(args)
self._paramspec_tvars = _paramspec_tvars
if not name:
self.__module__ = origin.__module__

Expand Down Expand Up @@ -1513,8 +1509,7 @@ def _make_substitution(self, args, new_arg_by_param):
return new_args

def copy_with(self, args):
return self.__class__(self.__origin__, args, name=self._name, inst=self._inst,
_paramspec_tvars=self._paramspec_tvars)
return self.__class__(self.__origin__, args, name=self._name, inst=self._inst)

def __repr__(self):
if self._name:
Expand Down Expand Up @@ -1624,8 +1619,7 @@ def __reduce__(self):
class _CallableType(_SpecialGenericAlias, _root=True):
def copy_with(self, params):
return _CallableGenericAlias(self.__origin__, params,
name=self._name, inst=self._inst,
_paramspec_tvars=True)
name=self._name, inst=self._inst)

def __getitem__(self, params):
if not isinstance(params, tuple) or len(params) != 2:
Expand Down Expand Up @@ -1869,8 +1863,7 @@ def __class_getitem__(cls, params):
new_args.append(new_arg)
params = tuple(new_args)

return _GenericAlias(cls, params,
_paramspec_tvars=True)
return _GenericAlias(cls, params)

def __init_subclass__(cls, *args, **kwargs):
super().__init_subclass__(*args, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove undocumented and unused ``_paramspec_tvars`` attribute from some
classes in :mod:`typing`.