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

Lock file maintenance #279

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions mex/common/types/email.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from pydantic import GetJsonSchemaHandler, json_schema
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler, json_schema
from pydantic_core import core_schema

EMAIL_PATTERN = r"^[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+$"
Expand All @@ -10,7 +10,9 @@ class Email(str):
"""Email address of a person, organization or other entity."""

@classmethod
def __get_pydantic_core_schema__(cls, source: type[Any]) -> core_schema.CoreSchema:
def __get_pydantic_core_schema__(
cls, source_type: Any, handler: GetCoreSchemaHandler
) -> core_schema.CoreSchema:
"""Modify the core schema to add the email regex."""
return core_schema.str_schema(pattern=EMAIL_PATTERN)

Expand Down
6 changes: 4 additions & 2 deletions mex/common/types/identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Self
from uuid import UUID, uuid4

from pydantic import GetJsonSchemaHandler, json_schema
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler, json_schema
from pydantic_core import core_schema

MEX_ID_ALPHABET = string.ascii_letters + string.digits
Expand Down Expand Up @@ -42,7 +42,9 @@ def validate(cls, value: Any) -> Self:
raise ValueError(f"Cannot parse {type(value)} as {cls.__name__}")

@classmethod
def __get_pydantic_core_schema__(cls, source: type[Any]) -> core_schema.CoreSchema:
def __get_pydantic_core_schema__(
cls, source_type: Any, handler: GetCoreSchemaHandler
) -> core_schema.CoreSchema:
"""Modify the core schema to add the ID regex."""
return core_schema.no_info_before_validator_function(
cls.validate, core_schema.str_schema(pattern=MEX_ID_PATTERN)
Expand Down
5 changes: 4 additions & 1 deletion mex/common/types/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path
from typing import Any, Self, Union

from pydantic import GetCoreSchemaHandler
from pydantic_core import core_schema


Expand Down Expand Up @@ -49,7 +50,9 @@ def is_relative(self) -> bool:
return not self._path.is_absolute()

@classmethod
def __get_pydantic_core_schema__(cls, source: type[Any]) -> core_schema.CoreSchema:
def __get_pydantic_core_schema__(
cls, source_type: Any, handler: GetCoreSchemaHandler
) -> core_schema.CoreSchema:
"""Set schema to str schema."""
from_str_schema = core_schema.chain_schema(
[
Expand Down
6 changes: 4 additions & 2 deletions mex/common/types/temporal_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, Literal, Union, cast, overload

from pandas._libs.tslibs import parsing
from pydantic import GetJsonSchemaHandler, json_schema
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler, json_schema
from pydantic_core import core_schema
from pytz import timezone

Expand Down Expand Up @@ -189,7 +189,9 @@ def _validate_precision(cls, precision: TemporalEntityPrecision) -> None:
raise ValueError(error_str)

@classmethod
def __get_pydantic_core_schema__(cls, source: type[Any]) -> core_schema.CoreSchema:
def __get_pydantic_core_schema__(
cls, source_type: Any, handler: GetCoreSchemaHandler
) -> core_schema.CoreSchema:
"""Modify the core schema to add validation and serialization rules."""
from_str_schema = core_schema.chain_schema(
[
Expand Down
Loading