Skip to content

Commit

Permalink
fix compatibility with 3.8-
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Aug 17, 2023
1 parent f8cf074 commit c1f947e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -11,6 +11,7 @@ sources = pydantic tests docs/plugins

.PHONY: install ## Install the package, dependencies, and pre-commit for local development
install: .pdm .pre-commit
pdm info
pdm install --group :all
pre-commit install --install-hooks

Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Expand Up @@ -4,7 +4,7 @@
from contextlib import nullcontext as does_not_raise
from decimal import Decimal
from inspect import signature
from typing import Any, ContextManager, Iterable, NamedTuple, Type, Union, get_type_hints
from typing import Any, ContextManager, Iterable, NamedTuple, Optional, Type, Union, get_type_hints

from dirty_equals import HasRepr, IsPartialDict
from pydantic_core import SchemaError, SchemaSerializer, SchemaValidator
Expand Down Expand Up @@ -738,7 +738,7 @@ def create_partial(model, optionals):
for name, field in model.model_fields.items():
if field.is_required() and name in optionals:
assert field.annotation is not None
override_fields[name] = ((field.annotation | None), FieldInfo.merge_field_infos(field, default=None))
override_fields[name] = (Optional[field.annotation], FieldInfo.merge_field_infos(field, default=None))

return create_model(f'Partial{model.__name__}', __base__=model, **override_fields)

Expand Down

0 comments on commit c1f947e

Please sign in to comment.