FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Replace `: Incomplete | None = None` with `=None`? · Issue #14029 · python/typeshed · GitHub

Repository navigation

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

Closed

Description

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.

Activity

  1. lev-blit commented on Oct 13, 2025

    Contributor

    This causes conflict with pyright strict mode, specifically reportUnknownParameterType (which probably comes together with reportMissingParameterType)

  2. srittau commented on Oct 13, 2025

    CollaboratorAuthor

    This causes conflict with pyright strict mode, specifically reportUnknownParameterType (which probably comes together with reportMissingParameterType)

    That's fine and expected. pyright not reporting reportMissingParameterType is actually a bit of an unintended side-effect of using Incomplete.

  3. lev-blit commented on Oct 14, 2025

    Contributor

    So packages which have incomplete with default None should be excluded from the stricter pyright?
    Seems like at some point we'd also like to check if there are packages who are "strict capable" (all parameters typed) and remove them from the exclusion

  4. AlexWaygood commented on Oct 14, 2025

    Member

    It's obviously not an ideal end state for any typeshed package to be incomplete. We welcome PRs to improve our stubs, if missing type annotations are causing issues for you when you enable pyright's strict mode!

  5. AlexWaygood commented on Oct 14, 2025

    Member

    So packages which have incomplete with default None should be excluded from the stricter pyright? Seems like at some point we'd also like to check if there are packages who are "strict capable" (all parameters typed) and remove them from the exclusion

    It's not part of typeshed's CI, but I do get an issue like this over at typeshed-stats if a package is "strict-ready" but is not tested with pyright's strict mode in typeshed's CI: AlexWaygood/typeshed-stats#369. So we're pretty good at keeping the list of packages excluded from pyright's strict mode in our CI to a minimum.

    We could fairly easily run that check in typeshed's CI if we added typeshed-stats as a test dependency.

  6. srittau commented on Oct 14, 2025

    CollaboratorAuthor

    Related: #14052

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL