-
Notifications
You must be signed in to change notification settings - Fork 5
Use narrower string type hints in the pydantic models #4
Open
Description
Love the work your team is doing on this standard! Our team is really getting a lot out of it.
The json schema uses enum where applicable, but the models in this project use str | None annotations. Since you're already using pydantic, I thought it would be beneficial to either use typing.Literal (likely preferred) or Enum annotations so that these can be validated upfront that they conform to the json schema.
I'm not sure if model.py was generated with any tools (i.e. datamodel-code-generator), but would you be open to a PR that makes the type hints narrower for the fields that have enums?
- OpenDataContractStandard.kind
- OpenDataContractStandard.apiVersion
- Server.type
- SchemaObject.logicalType
- SchemaProperty.logicalType
- DataQuality.dimension
- DataQuality.type
- DataQuality.metric
- Relationship.type
For example:
Current
class DataQuality(pyd.BaseModel): ... metric: str | None = None
Proposed
class DataQuality(pyd.BaseModel): ... metric: typing.Literal["nullValues", "missingValues", "invalidValues", "duplicateValues", "rowCount"] | None = None
I'd be happy to submit a PR if you're onboard with this idea. Thanks!
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.