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

Fix Ninja Schema Typing #1165

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

max-muoto
Copy link
Contributor

@max-muoto max-muoto commented May 15, 2024

Fix Ninja schema typing by adding a dataclass transformer, as specified in PEP 681. This transformer matches that of Pydantic's model metaclass.

Now, instead of Ninja schemas being typed as **kwargs: Any, one will get static type-checking on each field.

Fixes: #1094, #1050, #1053

Example:

CleanShot 2024-05-14 at 23 28 35@2x

@@ -29,6 +37,7 @@ def resolve_name(obj):
from pydantic._internal._model_construction import ModelMetaclass
from pydantic.functional_validators import ModelWrapValidatorHandler
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
from typing_extensions import dataclass_transform
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until the minimum is 3.11, we'll have to import from typing extensions.

@vitalik vitalik merged commit d44c774 into vitalik:master May 24, 2024
27 checks passed
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.

add dataclass_transform to enable better typehints
2 participants