-
-
Notifications
You must be signed in to change notification settings - Fork 98
feat add overloads for field types to improve type safety #1491
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
Merged
collerek
merged 8 commits into
ormar-orm:master
from
MaximSrour:update-stub-types-to-improve-type-safety
Jan 28, 2026
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b2787c
feat add overloads for field types to improve type safety
MaximSrour 29b176a
refactor into a neater format
MaximSrour 3ca9888
refactor migrate the types into a stub file
MaximSrour 2e117e4
refactor test model fields to use Optional type hints for nullable fi…
MaximSrour 840d134
Merge branch 'master' into update-stub-types-to-improve-type-safety
collerek 1022f41
Merge branch 'master' into update-stub-types-to-improve-type-safety
collerek 63193b0
fix: update the type overloads for boolean and enum fields
MaximSrour f71d08a
fix: consolidate superfluous LargeBinary type defs in stub file
MaximSrour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from datetime import date, datetime, time | ||
| from decimal import Decimal as DecimalType | ||
| from enum import Enum as EnumBase | ||
| from typing import Any, Literal, Type, TypeVar, overload | ||
| from uuid import UUID as UuidType | ||
|
|
||
| T = TypeVar("T", bound=EnumBase) | ||
|
|
||
| def Boolean(**kwargs: Any) -> bool: ... | ||
| @overload | ||
| def String( | ||
| *, max_length: int, nullable: Literal[False] = False, **kwargs: Any | ||
| ) -> str: ... | ||
| @overload | ||
| def String( | ||
| *, max_length: int, nullable: Literal[True], **kwargs: Any | ||
| ) -> str | None: ... | ||
| @overload | ||
| def Integer(*, nullable: Literal[False] = False, **kwargs: Any) -> int: ... | ||
| @overload | ||
| def Integer(*, nullable: Literal[True], **kwargs: Any) -> int | None: ... | ||
| @overload | ||
| def Text(*, nullable: Literal[False] = False, **kwargs: Any) -> str: ... | ||
| @overload | ||
| def Text(*, nullable: Literal[True], **kwargs: Any) -> str | None: ... | ||
| @overload | ||
| def Float(*, nullable: Literal[False] = False, **kwargs: Any) -> float: ... | ||
| @overload | ||
| def Float(*, nullable: Literal[True], **kwargs: Any) -> float | None: ... | ||
| @overload | ||
| def DateTime(*, nullable: Literal[False] = False, **kwargs: Any) -> datetime: ... | ||
| @overload | ||
| def DateTime(*, nullable: Literal[True], **kwargs: Any) -> datetime | None: ... | ||
| @overload | ||
| def Date(*, nullable: Literal[False] = False, **kwargs: Any) -> date: ... | ||
| @overload | ||
| def Date(*, nullable: Literal[True], **kwargs: Any) -> date | None: ... | ||
| @overload | ||
| def Time(*, nullable: Literal[False] = False, **kwargs: Any) -> time: ... | ||
| @overload | ||
| def Time(*, nullable: Literal[True], **kwargs: Any) -> time | None: ... | ||
| @overload | ||
| def JSON(*, nullable: Literal[False] = False, **kwargs: Any) -> Any: ... | ||
| @overload | ||
| def JSON(*, nullable: Literal[True], **kwargs: Any) -> Any | None: ... | ||
| @overload | ||
| def BigInteger(*, nullable: Literal[False] = False, **kwargs: Any) -> int: ... | ||
| @overload | ||
| def BigInteger(*, nullable: Literal[True], **kwargs: Any) -> int | None: ... | ||
| @overload | ||
| def SmallInteger(*, nullable: Literal[False] = False, **kwargs: Any) -> int: ... | ||
| @overload | ||
| def SmallInteger(*, nullable: Literal[True], **kwargs: Any) -> int | None: ... | ||
| @overload | ||
| def Decimal( | ||
| *, | ||
| max_digits: int, | ||
| decimal_places: int, | ||
| nullable: Literal[False] = False, | ||
| **kwargs: Any, | ||
| ) -> DecimalType: ... | ||
| @overload | ||
| def Decimal( | ||
| *, max_digits: int, decimal_places: int, nullable: Literal[True], **kwargs: Any | ||
| ) -> DecimalType | None: ... | ||
| @overload | ||
| def UUID(*, nullable: Literal[False] = False, **kwargs: Any) -> UuidType: ... | ||
| @overload | ||
| def UUID(*, nullable: Literal[True], **kwargs: Any) -> UuidType | None: ... | ||
| @overload | ||
| def LargeBinary( | ||
| max_length: int, *, represent_as_base64_str: Literal[True], **kwargs: Any | ||
| ) -> str: ... | ||
| @overload | ||
| def LargeBinary( | ||
| max_length: int, *, represent_as_base64_str: Literal[False], **kwargs: Any | ||
| ) -> bytes: ... | ||
| @overload | ||
| def LargeBinary( | ||
| max_length: int, represent_as_base64_str: Literal[False] = ..., **kwargs: Any | ||
| ) -> bytes: ... | ||
| def Enum(enum_class: Type[T], **kwargs: Any) -> T: ... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.