Skip to content

Conversation

@henryiii
Copy link
Collaborator

@henryiii henryiii commented Nov 18, 2025

Restructure the way we convert. Better error messages.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a to_project_table function that converts and validates dictionaries to PyProjectTable TypedDict at runtime. This enables runtime type checking of pyproject.toml data structures.

  • Added to_project_table() function for runtime type validation
  • Added _cast() helper function for recursive type checking
  • Improved Python 3.10 compatibility by making typing_extensions.Required optional

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pyproject_metadata/project_table.py Adds runtime type validation functions (to_project_table, _cast, is_typed_dict) and improves Required import handling for Python 3.10 compatibility
tests/test_project_table.py Comprehensive test coverage for the new conversion function, including success and error cases
pyproject.toml Adds linter exception for ERA001 (commented-out code) in project_table.py

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@henryiii henryiii force-pushed the henryiii/feat/to_project_table branch 2 times, most recently from 7fb6708 to 1d919c8 Compare November 18, 2025 23:14
@henryiii henryiii marked this pull request as draft November 18, 2025 23:14
@henryiii henryiii force-pushed the henryiii/feat/to_project_table branch from 1d919c8 to 4419e24 Compare November 19, 2025 03:02
@henryiii henryiii force-pushed the henryiii/feat/to_project_table branch from 9a8a187 to 2596540 Compare November 25, 2025 20:58
@henryiii henryiii force-pushed the henryiii/feat/to_project_table branch from 2596540 to 7ecfa56 Compare December 30, 2025 02:03
@henryiii henryiii requested a review from Copilot December 30, 2025 16:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +20
ParamSpec = typing.TypeVar
Concatenate = object
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback for ParamSpec and Concatenate on Python < 3.10 without typing_extensions will fail at runtime. On line 66, P.args and P.kwargs are accessed, but when ParamSpec is aliased to TypeVar (line 19), TypeVar instances don't have these attributes. Either add typing_extensions as a dependency for Python < 3.10, or implement a proper fallback class that provides args and kwargs attributes.

Suggested change
ParamSpec = typing.TypeVar
Concatenate = object
try:
from typing_extensions import Concatenate, ParamSpec
except ImportError:
def ParamSpec(name: str) -> typing.TypeVar:
tv = typing.TypeVar(name)
# Provide .args and .kwargs attributes so that annotations like
# *args: P.args, **kwargs: P.kwargs do not fail at runtime.
setattr(tv, "args", ())
setattr(tv, "kwargs", {})
return tv
class Concatenate:
"""Minimal runtime fallback for typing_extensions.Concatenate.
This is only used in type annotations; returning the argument from
__class_getitem__ is sufficient for annotations to evaluate.
"""
def __class_getitem__(cls, item):
return item

Copilot uses AI. Check for mistakes.
Comment on lines 920 to 924
"Field \"project.dynamic[0]\" expected one of 'authors', 'classifiers', "
"'dependencies', 'description', 'dynamic', 'entry-points', 'gui-scripts', "
"'import-names', 'import-namespaces', 'keywords', 'license', "
"'maintainers', 'optional-dependencies', 'readme', 'requires-python', "
"'scripts', 'urls', 'version' (got 'name')",
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implicit string concatenation. Maybe missing a comma?

Copilot uses AI. Check for mistakes.
@henryiii henryiii changed the title feat: add to_pyproject_table feat: restructure conversion Dec 30, 2025
@henryiii henryiii marked this pull request as ready for review December 30, 2025 22:21
@henryiii henryiii force-pushed the henryiii/feat/to_project_table branch from 86c8232 to a439731 Compare January 20, 2026 17:03
Signed-off-by: Henry Schreiner <[email protected]>
@henryiii henryiii force-pushed the henryiii/feat/to_project_table branch from 68e0f05 to 08aaedd Compare January 20, 2026 20:40
@henryiii henryiii merged commit b449f28 into main Jan 20, 2026
23 checks passed
@henryiii henryiii deleted the henryiii/feat/to_project_table branch January 20, 2026 21:16
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.

2 participants