Skip to content

Commit

Permalink
Fix typing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Mar 18, 2024
1 parent 178d7b7 commit 95eedff
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/galaxy/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Dict,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
)
Expand Down Expand Up @@ -126,16 +128,16 @@ class APIKeyModel(BaseModel):
# It should be removed when Python/pydantic supports this feature natively.
# https://github.com/pydantic/pydantic/issues/1673
def partial_model(
include: Optional[list[str]] = None, exclude: Optional[list[str]] = None
) -> Callable[[type[T]], type[T]]:
include: Optional[List[str]] = None, exclude: Optional[List[str]] = None
) -> Callable[[Type[T]], Type[T]]:
"""Decorator to make all model fields optional"""

if exclude is None:
exclude = []

@typing.no_type_check # Mypy doesn't understand pydantic's create_model
def decorator(model: type[T]) -> type[T]:
def make_optional(field: FieldInfo, default: Any = None) -> tuple[Any, FieldInfo]:
def decorator(model: Type[T]) -> Type[T]:
def make_optional(field: FieldInfo, default: Any = None) -> Tuple[Any, FieldInfo]:
new = deepcopy(field)
new.default = default
new.annotation = Optional[field.annotation or Any]
Expand Down

0 comments on commit 95eedff

Please sign in to comment.