-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use typing.overload
to improve type hints of pypika.terms
#19
Conversation
@@ -66,10 +67,31 @@ def tables_(self) -> set["Table"]: | |||
def fields_(self) -> set["Field"]: | |||
return set(self.find_(Field)) | |||
|
|||
if TYPE_CHECKING: # pragma: nocoverage | |||
|
|||
@typing.overload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like we are masking the bad typing problem instead of solving it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After there typing lines added, there are about 40 markers of type:ignore
removed!
def wrap_constant(val: tuple, wrapper_cls: Type[Term] | None = None) -> "Tuple": ... | ||
@typing.overload | ||
@staticmethod | ||
def wrap_constant(val: Any, wrapper_cls: None = None) -> "ValueWrapper": ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not like the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like such two functions(wrap_constant/wrap_json), they looks strange. It will be very great if you can refactor them...
cfc81e8
to
0b72eae
Compare
Hey, please have a look at my PR that removes these warnings without adding overloading. |
Does not change any logic, only type hints improve