Skip to content

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

Closed
@srittau

Description

@srittau

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    project: policyOrganization of the typeshed project

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions