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

Typing spec update for callables #28

Closed
5 tasks done
erictraut opened this issue May 4, 2024 · 2 comments
Closed
5 tasks done

Typing spec update for callables #28

erictraut opened this issue May 4, 2024 · 2 comments
Labels

Comments

@erictraut
Copy link
Collaborator

erictraut commented May 4, 2024

I'd like to request that the TC consider adoption of a new chapter in the typing spec that fills in some missing information about callables, including rules for subtyping.

Links to PR & Discussion
The PR can be found here. The latest draft incorporates feedback from PR reviews and the discussion.

The discussion can be found here.

TC Sign-off

  • Eric
  • Guido
  • Jelle
  • Rebecca
  • Shantanu

Current Type Checker Behaviors
Most of the update is simply documenting behaviors that type checkers exhibit today.

There is one aspect of the update that will require changes to all type checkers. It is related to the treatment of (*args: Any, **kwargs: Any) as the same as ... in a Callable annotation. The behavior in the draft specification is close to what mypy currently implements, but there are some differences that will require small changes in mypy. The other three major type checkers do not currently treat (*args: Any, **kwargs: Any) specially, so they will require updates to conform to the proposed spec.

Controversial Issues
The only controversial issue relates to the special treatment of (*args: Any, **kwargs: Any). Some people (myself included) would prefer not to treat this specially, but taking into consideration mypy's historical behavior and the pain involved in changing it, a compromise makes sense here. It is not dissimilar to the decision we made for tuple[Any, ...].

@rchen152
Copy link
Collaborator

rchen152 commented May 5, 2024

I signed off. I'm not a huge fan of special-casing (*args: Any, **kwargs: Any), but it seems like a reasonable compromise.

@gvanrossum
Copy link
Member

I sent a PR review with some optional editorial nits, and signed off. Glad to see this concluded!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants