Skip to content

Optional dependencies #15549

@srittau

Description

@srittau

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    project: infrastructuretypeshed build, test, documentation, or distribution related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions