See #15548 for an example of this problem.
Currently, we don't support optional dependencies in typeshed. Say a third-party package has some additional functionality if another third-party package is installed. For example, Authlib has a module authlib.integrations.requests_client that works only if requests is also installed. This leads to the awkward situation that our stubs for that module have many comments of the form "Inherits from requests.Session".
I suggest that we should add support for optional dependencies. Here's an idea:
- Add a field
optional-requires to METADATA.toml. stub_uploader checks that this has the same limitations as requires.
- In tests
optional-requires is treated the same way that requires is, i.e. the packages mentioned there are installed.
- stub_uploader adds this new field to
project.optional-dependencies in pyproject.toml.
(Sidenote: Maybe we should rename requires to dependencies to match pyproject.toml.)
See #15548 for an example of this problem.
Currently, we don't support optional dependencies in typeshed. Say a third-party package has some additional functionality if another third-party package is installed. For example,
Authlibhas a moduleauthlib.integrations.requests_clientthat works only ifrequestsis also installed. This leads to the awkward situation that our stubs for that module have many comments of the form "Inherits from requests.Session".I suggest that we should add support for optional dependencies. Here's an idea:
optional-requirestoMETADATA.toml. stub_uploader checks that this has the same limitations asrequires.optional-requiresis treated the same way thatrequiresis, i.e. the packages mentioned there are installed.project.optional-dependenciesinpyproject.toml.(Sidenote: Maybe we should rename
requirestodependenciesto matchpyproject.toml.)