-
Notifications
You must be signed in to change notification settings - Fork 9
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
Typing fixes in config.py #307
Conversation
@@ -32,7 +32,7 @@ def getenv(env_var: str, default: T) -> Union[str, T]:... | |||
@overload | |||
def getenv(env_var: str) -> str:... | |||
|
|||
def getenv(env_var: str, default: T = NOT_PROVIDED) -> Union[str, T]: | |||
def getenv(env_var: str, default = NOT_PROVIDED) -> str: |
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 is inconsistent/not how @overload
works. @overload
ed function signatures narrow down the return type, given a particular choice of argument types. Annotations on the function implementation itself (without @overload
) should be a strict superset of the @overload
ed ones. Here, str
is a subset of Union[str, T]
.
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.
could we make 1 function always return 1 type (str
in this case) and use a different funcition name for the other types? or what is the benefit of the overload / generics type?
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.
@MatthewBaggins originally it was default: T = NOT_PROVIDED
, but this raised typing errors saying NOT_PROVIDED
was type str, not T. This change fixes that error, with no other errors raised anywhere else in the file. What do you think needs to be different?
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.
@MatthewBaggins I'm going to go ahead and merge, let me know if you have an alternative way to do it that doesn't raise errors.
885c553
to
3a765c4
Compare
No description provided.