Optional dependencies
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
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-requirestoMETADATA.toml. stub_uploader checks that this has the same limitations asrequires. - In tests
optional-requiresis treated the same way thatrequiresis, i.e. the packages mentioned there are installed. stub_uploader adds this new field toproject.optional-dependenciesinpyproject.toml.
(Sidenote: Maybe we should rename requires to dependencies to match pyproject.toml.)
Linked PR:
- typeshed-internal/stub_uploader#203
- typeshed-internal/stub_uploader#208
- #15706
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the METADATA.toml handling and stub_uploader validation, then inspect the tests that install packages from requires. Define the optional-requires metadata behavior and verify that the relevant packages are installed for tests, while checking the referenced stub_uploader PRs and #15706 for existing decisions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100