Skip to content

Add PEP 735 dependency groups to pyproject.toml's schema#4139

Merged
hyperupcall merged 2 commits into
SchemaStore:masterfrom
InSyncWithFoo:master
Oct 12, 2024
Merged

Add PEP 735 dependency groups to pyproject.toml's schema#4139
hyperupcall merged 2 commits into
SchemaStore:masterfrom
InSyncWithFoo:master

Conversation

@InSyncWithFoo

@InSyncWithFoo InSyncWithFoo commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

PEP 735 has just been accepted. As I understand it, the PEP introduces a new top-level dependency-groups table whose:

  • Each property key must be a valid non-normalized name.
  • Each property value must be an array, of which each element is either:
    • A PEP 508 dependency specifiers.
    • An inline table consisting of exactly one property, include-group, and this property's value must be another group's name.

In Python's typing system:

# (?i)^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$
type GroupName = str

# PEP 508
type DependencySpecifier = str

DependencyGroupInclude = TypedDict('DependencyGroupInclude', {
    "include-group": GroupName
})

type DependencyGroup = list[DependencySpecifier | DependencyGroupInclude]
type DependencyGroupsTable = dict[GroupName, DependencyGroup]

Most tests were copied from the PEP itself.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR!

This section of the codebase is owned by @madskristensen and @hyperupcall - if they write a comment saying "LGTM" then it will be merged.

@sirosen

sirosen commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

Thanks for adding this! I was going to make the change myself, thinking there were one or two people who might also pick it up, but then somebody else got it done! Open source is so cool sometimes. ❤️

cc @henryiii, this looks good to me. I would probably have declared it with patternProperties, but I think this use of additionalProperties is equivalent.

@henryiii

Copy link
Copy Markdown
Contributor

I've had issues with additionalProperties not being as well supported as patternProperties in the past in validate-pyproject; that's why I went with that in abravalheri/validate-pyproject#208. If it's passing tests I'd not worry about it, though.

@henryiii

Copy link
Copy Markdown
Contributor

FWIW, since this is based on a pattern, I think patternProperties is actually a little nicer (with additionalProperties set to false).

@henryiii

Copy link
Copy Markdown
Contributor

If anyone needs the link to PEP 735, the one in the description has a typo, it's actually https://peps.python.org/pep-0735/.

@InSyncWithFoo

Copy link
Copy Markdown
Contributor Author

[...] the one in the description has a typo [...]

Fixed.

@hyperupcall

Copy link
Copy Markdown
Member

Awesome, thanks!

@hyperupcall hyperupcall merged commit 6e765dd into SchemaStore:master Oct 12, 2024
benpops89 pushed a commit to benpops89/schemastore that referenced this pull request Nov 21, 2024
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.

4 participants