Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace : Incomplete | None = None with =None? #14029

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

Open
srittau opened this issue May 12, 2025 · 0 comments
Open

Replace : Incomplete | None = None with =None? #14029

srittau opened this issue May 12, 2025 · 0 comments
Labels
project: policy Organization of the typeshed project

Comments

@srittau
Copy link
Collaborator

srittau commented May 12, 2025

From #14027

The form Incomplete | None = None is basically a holdover from before we included defaults in stubs, where Incomplete | None = ... provided extra information.

In #14027 @Avasam wrote:

This is still interpreted as Any | None by mypy. And now more correctly interpreted as Unknown | None by pyright.

Unknown | None instead of Any | None sounds like this would be worth it alone. I also like that this form would be more succinct, while being quite obvious.

@Avasam also wrote:

Some stubs might also use it in select places specifically to pass pyrightconfig.stricter.json

This is something we need to look out for, but is - in my opinion - not a valid reason not to do this. Marking something as "strict" when it's using Incomplete is cheating anyway, and we don't allow bare Incomplete statements.

Whatever we decide, we should enforce the style using flake8-pyi.

If we change this, we should also ask mypy to change stubgen to follow this style.

@srittau srittau added the project: policy Organization of the typeshed project label May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: policy Organization of the typeshed project
Projects
None yet
Development

No branches or pull requests

1 participant