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

PEP 612 (Parameter Specification variables) tracker #4827

Closed
8 tasks done
srittau opened this issue Dec 16, 2020 · 22 comments
Closed
8 tasks done

PEP 612 (Parameter Specification variables) tracker #4827

srittau opened this issue Dec 16, 2020 · 22 comments
Labels
project: feature tracker Tracks whether a typing feature can be used in typeshed stubs

Comments

@srittau
Copy link
Collaborator

srittau commented Dec 16, 2020

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:

@srittau
Copy link
Collaborator Author

srittau commented Dec 16, 2020

@mrkmndz I assume pyre already supports these?

@mrkmndz
Copy link
Contributor

mrkmndz commented Dec 16, 2020

Yup!

@erictraut
Copy link
Contributor

Pyright has had full support for PEP 612 for a long time now.

@srittau srittau added the project: feature tracker Tracks whether a typing feature can be used in typeshed stubs label Jan 6, 2021
@srittau
Copy link
Collaborator Author

srittau commented 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
Copy link
Collaborator

rchen152 commented Jan 7, 2021

pytype does not yet support this. I opened google/pytype#786.

@srittau
Copy link
Collaborator Author

srittau commented Jan 25, 2021

Cc @sproshev

@sproshev
Copy link
Contributor

Not yet planned :( Will post updates here.

@sproshev
Copy link
Contributor

Planned: https://youtrack.jetbrains.com/issue/PY-47899

@erictraut
Copy link
Contributor

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.

@JelleZijlstra
Copy link
Member

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
Copy link
Collaborator Author

srittau commented Jun 14, 2021

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.

@JelleZijlstra
Copy link
Member

Maybe we could have a draft PR that implements ParamSpec in a file where it's useful to judge the fallout?

#5476

@srittau
Copy link
Collaborator Author

srittau commented Jun 14, 2021

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.

@srittau
Copy link
Collaborator Author

srittau commented Jun 28, 2021

mypy still seems to have problems with Concatenate in Callable, see #5682.

@AlexWaygood
Copy link
Member

According to this and this, it seems PyCharm now supports ParamSpec 🎉

@lancelote
Copy link
Contributor

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.

@srittau
Copy link
Collaborator Author

srittau commented Dec 22, 2021

Now partly supported by mypy, no support for Concatenate yet.

@srittau
Copy link
Collaborator Author

srittau commented Dec 23, 2021

I checkmarked pytype. While it doesn't support ParamSpec per se, it accepts it.

JukkaL pushed a commit to python/mypy that referenced this issue Apr 7, 2022
This PR adds a new Parameters proper type to represent ParamSpec parameters 
(more about this in the PR), along with supporting the Concatenate operator.

Closes #11833
Closes #12276
Closes #12257
Refs #8645
External ref python/typeshed#4827

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
@srittau
Copy link
Collaborator Author

srittau commented May 21, 2022

I think we can now use ParamSpec without limitations in typeshed.

@srittau srittau closed this as completed May 21, 2022
@AlexWaygood
Copy link
Member

I think we can now use ParamSpec without limitations in typeshed.

There's still a mypy bug I'm waiting on: #7689 (comment). I'll add it to the tracker.

@AlexWaygood AlexWaygood reopened this May 21, 2022
@mavidser

This comment was marked as off-topic.

@AlexWaygood
Copy link
Member

AlexWaygood commented Feb 12, 2023

I think we can now use ParamSpec without limitations in typeshed.

There's still a mypy bug I'm waiting on: #7689 (comment). I'll add it to the tracker.

The mypy issue has now been closed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: feature tracker Tracks whether a typing feature can be used in typeshed stubs
Projects
None yet
Development

No branches or pull requests

9 participants