Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add types for PEP 735 #203

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions pyproject_metadata/project_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import annotations

import sys
import typing
from typing import Any, Dict, List, Union

if sys.version_info < (3, 11):
Expand All @@ -28,6 +29,7 @@
"BuildSystemTable",
"ContactTable",
"Dynamic",
"IncludeGroupTable",
"LicenseTable",
"ProjectTable",
"PyProjectTable",
Expand Down Expand Up @@ -107,12 +109,44 @@ class LicenseTable(TypedDict, total=False):
total=False,
)

# total=False here because this could be
# extended in the future
IncludeGroupTable = TypedDict(
"IncludeGroupTable",
{"include-group": str},
total=False,
)

PyProjectTable = TypedDict(
"PyProjectTable",
{
"build-system": BuildSystemTable,
"project": ProjectTable,
"tool": Dict[str, Any],
"dependency-groups": Dict[str, List[Union[str, IncludeGroupTable]]],
},
total=False,
)

# Tests for type checking
if typing.TYPE_CHECKING:
PyProjectTable(
{
"build-system": BuildSystemTable(
{"build-backend": "one", "requires": ["two"]}
),
"project": ProjectTable(
{
"name": "one",
"version": "0.1.0",
}
),
"tool": {"thing": object()},
"dependency-groups": {
"one": [
"one",
IncludeGroupTable({"include-group": "two"}),
]
},
}
)