Description
Feature
I would like stubtest to support checking the type_check_only
decorator.
This means something marked with type_check_only
that DOES exist at runtime is an error.
And something that DOES NOT exist at runtime, and is marked with type_check_only
should pass.
Pitch
Instead of marking stub-only classes and methods as private in typeshed, they can be marked with @type_check_only
, which is designed for that exact purpose. Private may or may not be found at runtime, and users sometimes don't have a choice to use them, and basically have to guess whether they need to wrap the import in TYPE_CHECK_ONLY
or not.
This would also promote marking as type_check_only
special methods that don't exist at runtime, but are added to support some typechecker features, in typeshed.
Related: #9531