Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.47 KB

File metadata and controls

43 lines (32 loc) · 1.47 KB

Utility types for typeshed

This package and its submodules contain various common types used by typeshed. It can also be used by packages outside typeshed, but beware the API stability guarantees below.

Usage

The _typeshed package and its types do not exist at runtime, but can be used freely in stubs (.pyi) files. To import the types from this package in implementation (.py) files, use the following construct:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from _typeshed import ...

Types can then be used in annotations by either quoting them or using:

from __future__ import annotations

API Stability

You can use this package and its submodules outside of typeshed, but we guarantee only limited API stability. Items marked as "stable" will not be removed or changed in an incompatible way for at least one year. Before making such a change, the "stable" moniker will be removed and we will mark the type in question as deprecated. No guarantees are made about unmarked types.

Use in 3rd-party Packages (stubs)

The _typeshed module is usually vendored by type checkers. To ensure that type checkers have a chance to pick up changes to this module, items added to _typeshed (or its submodules) have a two month cooldown period before they can be used in third-party stubs. For example, if _typeshed.Fruzzle is added on 2026-07-15, it can't be used before 2026-09-15. This restriction does not apply to standard library stubs.