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

Improve readline typings #7141

Merged
merged 3 commits into from
Feb 6, 2022
Merged

Improve readline typings #7141

merged 3 commits into from
Feb 6, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Feb 5, 2022

Changes:

  1. For some reason, this module was using old style Optional, is this a bug?
  2. set_startup_hook can take any callable, the return type is ignored

@github-actions

This comment has been minimized.

@Akuli
Copy link
Collaborator

Akuli commented Feb 5, 2022

this module was using old style Optional, is this a bug?

Type aliases still use old-style Optional and Union, because mypy had bugs where they didn't work in type aliases. There's still a bug that makes _Color = str | tuple[float, float, float] not work, and once that is fixed, we can apply the new syntax to type aliases too.

_CompleterT = Optional[Callable[[str, int], Optional[str]]]
_CompDispT = Optional[Callable[[str, Sequence[str], int], None]]
_CompleterT = Callable[[str, int], str | None]
_CompDispT = Callable[[str, Sequence[str], int], None]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These shouldn't be named ending with T, because they aren't type variables.

@AlexWaygood
Copy link
Member

  1. For some reason, this module was using old style Optional, is this a bug?

python/mypy#11098 is the relevant mypy issue if you wanna help us get to a place where we can use PEP 604 syntax everywhere in typeshed ;) I tried looking at it today for a little while, but understanding the mypy codebase is still a little like wading through treacle for me :(

@github-actions

This comment has been minimized.

@Akuli Akuli closed this Feb 6, 2022
@Akuli Akuli reopened this Feb 6, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@Akuli Akuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Akuli Akuli merged commit 8cb1518 into python:master Feb 6, 2022
@sobolevn
Copy link
Member Author

sobolevn commented Feb 6, 2022

Thanks for the review! I am trying to fix mypy to allow tuple aliases. See python/mypy#12134

I hope it can make its way into 0.940

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

Successfully merging this pull request may close these issues.

None yet

3 participants