Skip to content

Underscore for type-check only items? #11122

@srittau

Description

@srittau

Just a random thought: When we add classes or type aliases to stubs that aren't available at runtime, but could be useful for users as well (by using if TYPE_CHECKING:), we currently prefix them with an underscore. This has two disadvantages:

  1. Linters and IDEs (as well as the linter in my brain) often mark them as "using a private item from an external module". This isn't really the case here as we support the use of these items during type checking.
  2. It doesn't really communicate the fact that the item is available during type-check only.

Maybe it would make sense to come up with another convention to mark these type-check only? The (admittedly failed) @type_check_only decorator doesn't really help in this situation, as it marks the items only when defining them, not when importing them. It also doesn't work with type aliases.

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