|
54 | 54 | sort_dict, |
55 | 55 | ) |
56 | 56 |
|
| 57 | +pydantic_version = version.parse(pydantic.__version__) |
| 58 | + |
| 59 | +if pydantic_version >= version.parse("2.10"): |
| 60 | + literal_values = _typing_extra.literal_values |
| 61 | +else: |
| 62 | + literal_values = _typing_extra.all_literal_values |
| 63 | + |
57 | 64 | logger = logging.getLogger(__name__) |
58 | 65 |
|
59 | 66 | # Callable to sort a dictionary by its keys case-insensitively |
@@ -406,9 +413,7 @@ def _build_schema_type_to_method( |
406 | 413 | for one of the schema or field types |
407 | 414 | """ |
408 | 415 | mapping: dict[CoreSchemaOrFieldType, Callable[[CoreSchemaOrField], None]] = {} |
409 | | - core_schema_types: list[ |
410 | | - CoreSchemaOrFieldType |
411 | | - ] = _typing_extra.all_literal_values( |
| 416 | + core_schema_types: list[CoreSchemaOrFieldType] = literal_values( |
412 | 417 | CoreSchemaOrFieldType # type: ignore |
413 | 418 | ) |
414 | 419 | for key in core_schema_types: |
@@ -465,6 +470,11 @@ def _attach_note(self, note: str) -> None: |
465 | 470 | """ |
466 | 471 | self._slot.notes.append(f"{__package__}: {note}") |
467 | 472 |
|
| 473 | + if pydantic_version >= version.parse("2.10"): |
| 474 | + |
| 475 | + def _invalid_schema(self, schema: core_schema.InvalidSchema) -> None: |
| 476 | + raise TranslationNotImplementedError(schema) |
| 477 | + |
468 | 478 | def _any_schema(self, _schema: core_schema.AnySchema) -> None: |
469 | 479 | """ |
470 | 480 | Shape the contained slot definition to match any value |
@@ -1307,7 +1317,7 @@ def _typed_dict_field_schema(self, schema: core_schema.TypedDictField) -> None: |
1307 | 1317 | def _computed_field_schema(self, schema: core_schema.ComputedField) -> None: |
1308 | 1318 | raise TranslationNotImplementedError(schema) |
1309 | 1319 |
|
1310 | | - if version.parse(pydantic.__version__) >= version.parse("2.9"): |
| 1320 | + if pydantic_version >= version.parse("2.9"): |
1311 | 1321 | # Methods define when Pydantic version is 2.9 or later |
1312 | 1322 | def _complex_schema(self, schema: core_schema.ComplexSchema) -> None: |
1313 | 1323 | raise TranslationNotImplementedError(schema) |
|
0 commit comments