-
Notifications
You must be signed in to change notification settings - Fork 2
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
Release v1.3.1 #22
Release v1.3.1 #22
Conversation
* Begin fixing mypy errors * Add types-requests dependency * Finish fixing mypy errors
* Begin fixing mypy errors * Add types-requests dependency * Finish fixing mypy errors
@overload | ||
def retry(func: F) -> F: ... |
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.
adding this actually breaks the use case i resolved in the previous PR. do we need just these 2 lines?
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.
Hmm, mypy and pylance didn't complain, let me look into it. Thanks for letting me know!
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.
thanks.... i use mypy and it never complained in my project also so i was little surprised with airflow issues. I do use the latest mypy.
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.
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.
Have the method take a param in like this def get_example(x: int) -> Payload | None:
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.
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.
Here is the complete code and you will see how lower example is getting confused. Very tricky lol
from uuid import UUID
from pydantic import BaseModel
import httpx
from retryhttp._retry import retry
class Payload(BaseModel):
uuid: UUID
id: int
user_id: int
user_uuid: UUID
class Defaults(BaseModel):
timeout: int = 3
backoff: bool = True
defaults1 = {
"timeout": 5,
"backoff": True,
}
defaults2 = Defaults().model_dump()
@retry(**defaults1)
def get_example1(x: int) -> Payload:
response = httpx.get("https://example.com/")
response.raise_for_status()
return Payload(**response.json())
x = get_example1(1).user_id
@retry(**defaults2)
def get_example2(x: int) -> Payload:
response = httpx.get("https://example.com/")
response.raise_for_status()
return Payload(**response.json())
x = get_example2(1).user_id
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.
one of the solution is to change the defaults2 init to defaults2: dict = Defaults().model_dump()
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.
The testing I did suggests the issue is model_dump()
's return type. this is an unusual case (why are you using a pydantic model for kwargs?) and I'm not sure there's anything wrong with the decorator's type signatures. You're welcome to experiment--let me know if you find something that works! Just be sure it works with mypy too :)
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.
Honestly, not a big deal as its a minor nuance. Maybe future versions of pylance can improve this. i think we are good for now. 😄 thanks for your support.
No description provided.