You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PEP 612 (Parameter Specification variables) tracker #4827
This issue is supposed to track when we can start to use parameter specification variables (PEP 612) in typeshed. Support is needed in released versions of:
Is there any update on this issue? Has anyone started to work on the support in mypy? Pytype?
I'm aware that full support for PEP 612 is not easy to implement, but perhaps some minimal support could be added that simply treats all ParamSpecs as Any? That would allow us to start using ParamSpec and Concatenate within typeshed without regressing the behavior for mypy users. This minimal support apparently was already implemented in pytype. It looks like @hauntsaninja made some progress on support in mypy in this PR, but there hasn't been any update in this tracking issue since Jan 2020.
Maybe we need to think about ways to support declarations that are conditioned on support for specific type checking features. Perhaps something like a _typing_features.pyi file that defines symbols like __PEP612__. Type checkers that support specific features could assume these symbols are True and use the type declarations that take advantage of these features. Type checkers that don't support the feature would assume False and fall back on alternate declarations that don't use these features.
Another, more forceful, approach could be that we simply start using them in typeshed (perhaps with a liberal sprinkling of type ignores). It would then be individual type checkers' responsibilities to add support for new features, and the ecosystem can move forward without having to wait for the slowest type checker to update itself. We could start doing this say six months or a year after a PEP has been accepted.
Could we just cheat and derive ParamSpec from Any in typing_extensions, until type checkers add support? That said, I'm also fine to just start using ParamSpec and use # type: ignore. Maybe we could have a draft PR that implements ParamSpec in a file where it's useful to judge the fallout?
But in general I agree that we should be more aggressive about adding features, so as not to hold more up-to-date type checkers back.
ParamSpec can now be used in argument and return type positions, although # type: ignore is necessary. It's still untested whether it works as part of a Generic class.
Yeap, though there are some issues and limitations in PyCharm ParamSpec support atm. I organized the known problems in this meta ticket PY-51766. Feel free to report anything I've missed.
Activity
srittau commentedon Dec 16, 2020
@mrkmndz I assume pyre already supports these?
mrkmndz commentedon Dec 16, 2020
Yup!
erictraut commentedon Jan 4, 2021
Pyright has had full support for PEP 612 for a long time now.
srittau commentedon Jan 6, 2021
@rchen152 Does pytype support PEP 612? If not, would you mind me creating a ticket that we can reference from here?
rchen152 commentedon Jan 7, 2021
pytype does not yet support this. I opened google/pytype#786.
srittau commentedon Jan 25, 2021
Cc @sproshev
sproshev commentedon Jan 25, 2021
Not yet planned :( Will post updates here.
sproshev commentedon Mar 31, 2021
Planned: https://youtrack.jetbrains.com/issue/PY-47899
erictraut commentedon Jun 13, 2021
Is there any update on this issue? Has anyone started to work on the support in mypy? Pytype?
I'm aware that full support for PEP 612 is not easy to implement, but perhaps some minimal support could be added that simply treats all ParamSpecs as
Any? That would allow us to start usingParamSpecandConcatenatewithin typeshed without regressing the behavior for mypy users. This minimal support apparently was already implemented in pytype. It looks like @hauntsaninja made some progress on support in mypy in this PR, but there hasn't been any update in this tracking issue since Jan 2020.Maybe we need to think about ways to support declarations that are conditioned on support for specific type checking features. Perhaps something like a
_typing_features.pyifile that defines symbols like__PEP612__. Type checkers that support specific features could assume these symbols areTrueand use the type declarations that take advantage of these features. Type checkers that don't support the feature would assumeFalseand fall back on alternate declarations that don't use these features.JelleZijlstra commentedon Jun 13, 2021
I think work on mypy support has stalled.
Another, more forceful, approach could be that we simply start using them in typeshed (perhaps with a liberal sprinkling of type ignores). It would then be individual type checkers' responsibilities to add support for new features, and the ecosystem can move forward without having to wait for the slowest type checker to update itself. We could start doing this say six months or a year after a PEP has been accepted.
srittau commentedon Jun 14, 2021
Could we just cheat and derive
ParamSpecfromAnyintyping_extensions, until type checkers add support? That said, I'm also fine to just start usingParamSpecand use# type: ignore. Maybe we could have a draft PR that implementsParamSpecin a file where it's useful to judge the fallout?But in general I agree that we should be more aggressive about adding features, so as not to hold more up-to-date type checkers back.
JelleZijlstra commentedon Jun 14, 2021
#5476
srittau commentedon Jun 14, 2021
ParamSpeccan now be used in argument and return type positions, although# type: ignoreis necessary. It's still untested whether it works as part of aGenericclass.srittau commentedon Jun 28, 2021
mypy still seems to have problems with
ConcatenateinCallable, see #5682.AlexWaygood commentedon Dec 2, 2021
According to this and this, it seems PyCharm now supports
ParamSpec🎉lancelote commentedon Dec 2, 2021
Yeap, though there are some issues and limitations in PyCharm
ParamSpecsupport atm. I organized the known problems in this meta ticket PY-51766. Feel free to report anything I've missed.srittau commentedon Dec 22, 2021
Now partly supported by mypy, no support for
Concatenateyet.srittau commentedon Dec 23, 2021
I checkmarked pytype. While it doesn't support
ParamSpecper se, it accepts it.Basic ParamSpec Concatenate and literal support (#11847)
srittau commentedon May 21, 2022
I think we can now use ParamSpec without limitations in typeshed.
AlexWaygood commentedon May 21, 2022
There's still a mypy bug I'm waiting on: #7689 (comment). I'll add it to the tracker.
mavidser commentedon May 24, 2022
AlexWaygood commentedon Feb 12, 2023
The mypy issue has now been closed!