Each third-party stub package must have a metadata file to describe the
package. For example, the metadata for a package parrot lives in
stubs/parrot/METADATA.toml.
Metadata files use the TOML file format. Currently, the following keys are supported:
version: The versions of the library that the stubs support. Two formats are supported:- A concrete version. This is especially suited for libraries that use Calendar Versioning.
- A version range ending in
.*. This is suited for libraries that reflect API changes in the version number only, where the API-independent part is represented by the asterisk. In the case of Semantic Versioning, this version could look like this:2.7.*. When the stubs are updated to a newer version of the library, the version of the stub should be bumped (note that previous versions are still available on PyPI).
dependencies(optional): A list of other stub packages or packages with type information that are imported by the stubs in this package. Only packages generated by typeshed or required by the upstream package are allowed to be listed here, for security reasons. See this issue for more information about what external dependencies are allowed.optional-dependencies(optional): A list of other stub packages or packages with type information that are imported by some stubs in this package. This is often used for packages that provide optional features that require extra dependencies. The same limitations apply to this field as todependencies.extra-description(optional): Can be used to add a custom description to the package's long description. It should be a multi-line string in Markdown format.stub-distribution(optional): Distribution name to be uploaded to PyPI. This defaults totypes-<distribution>and should only be set in special cases.upstream-repository(recommended): The URL of the upstream repository.obsolete-since(optional): This table is part of our process for removing obsolete third-party libraries. It contains the first version of the corresponding library that ships its ownpy.typedfile, and the date when that version was released.no-longer-updated(optional): This field is set totruebefore removing stubs for other reasons than the upstream library shipping with type information.upload(optional): This field is set tofalseto prevent automatic uploads to PyPI. This should only be used in special cases, e.g. when the stubs break the upload.partial-stub(optional): This field marks the type stub package as partial. This is for 3rd-party stubs that don't cover the entirety of the package's public API.requires-python(optional): The minimum version of Python required to install the type stub package. It must be in the form>=3.*. If omitted, the oldest Python version supported by typeshed is used.
In addition, we specify configuration for stubtest in the tool.stubtest table.
This has the following keys:
skip(default:false): Whether stubtest should be run against this package. Please avoid setting this totrue, and add a comment if you have to.ignore-missing-stub(default:false): When set totrue, this will add the--ignore-missing-stuboption to the stubtest call. See tests/README.md for more information. In most cases, this field should be identical topartial-stub.stubtest-dependencies(default:[]): A list of Python packages that need to be installed for stubtest to run successfully. These packages are installed in addition to the dependencies in thedependenciesandoptional-dependenciesfields.apt-dependencies(default:[]): A list of Ubuntu APT packages that need to be installed for stubtest to run successfully.brew-dependencies(default:[]): A list of MacOS Homebrew packages that need to be installed for stubtest to run successfullychoco-dependencies(default:[]): A list of Windows Chocolatey packages that need to be installed for stubtest to run successfullyextras(default:[]): A list of optional dependency groups (extras) that need to be installed for stubtest to run successfully. For example,extras = ["foo"]installs the package as<package>[foo].supported-platforms(default: all platforms): A list of OSes on which stubtest can be run. When a package is not platform-specific, this should not be set. If the package is platform-specific, this should usually be set to the supported platforms, unless stubtest is known to fail on a specific platform.ci-platforms(default:["linux"]): A list of OSes on which to run stubtest as part of our continuous integration (CI) tests. Can containwin32,linux, anddarwinvalues. If not specified, stubtest is run only onlinux. Only add extra OSes to the test if there are platform-specific branches in a stubs package.mypy-plugins(default:[]): A list of Python modules to use as mypy plugins when running stubtest. For example:mypy-plugins = ["mypy_django_plugin.main"]mypy-plugins-config(default:{}): A dictionary mapping plugin names to their configuration dictionaries for use by mypy plugins. For example:mypy-plugins-config = {"django-stubs" = {"django_settings_module" = "@tests.django_settings"}}install-environment(default:{}): A dictionary of environment variables to set whilepip installing the package and its dependencies for stubtest. Useful for packages that read build-time options from the environment, for example to disable CPU-specific compiler flags that do not survive CI's shared wheel cache. For example:install-environment = { HNSWLIB_NO_NATIVE = "1" }
*-dependencies are usually packages needed to pip install the implementation
distribution.
The format of all METADATA.toml files can be checked by running
python3 ./tests/check_typeshed_structure.py.