Skip to content

Refactor dependency handling#203

Open
srittau wants to merge 5 commits into
mainfrom
refactor-dependencies
Open

Refactor dependency handling#203
srittau wants to merge 5 commits into
mainfrom
refactor-dependencies

Conversation

@srittau

@srittau srittau commented May 7, 2026

Copy link
Copy Markdown
Member

This is a prerequisite for optional-dependencies handling.

The dependency handling has evolved in the past. Unfortunately that made it quite convoluted over time and it's now hard to add features to it. This PR is supposed to simplify dependency handling. It is best reviewed commit-by-commit. The commit comments have additional information.

srittau added 2 commits May 7, 2026 16:22
Don't let `Metadata`, `verify_typeshed_req`, `verify_external_req`,
and `verify_external_req_not_in_typeshed` read the typeshed
directory themselves. Instead, expect the names of typeshed packages
as an argument.

This will not only allow easier testing in the future, it's also a first
step towards a less confusing dependencies interface. It also means that
`Metadata` is now a pure (side-effect free) class, making it easier to
reason about.
* We now wrap `packaging.requirements.Requirements` instances with a
  `Dependency` class that allows us to distinguish between typeshed and
  external dependencies. In the future, it's planned that this also
  gains a `optional` flag for support of `optional-dependencies`.
* `Metadata` now only has a `dependencies` property. This will perform
  all necessary validation and return a list of all dependencies as
  needed by the pyproject.toml template. The tests now also verify just
  this field.
* Some verification functions have become methods on the `Metadata`
  class, so they can access "private" fields.
* Some verification has moved onto the `Dependency` class as an
  invariant. Typeshed dependencies need to start with `types-`, and
  external depencies must not start with `types-`.
@srittau

srittau commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

See python/typeshed#15549 for the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant