Skip to content
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

Merged
merged 9 commits into from
Feb 5, 2025
Merged

Release v1.3.1 #22

merged 9 commits into from
Feb 5, 2025

Conversation

austind
Copy link
Owner

@austind austind commented Feb 5, 2025

No description provided.

* Add default fallback

* Update changelog

* Version fix

* Fix test
* Begin fixing mypy errors

* Add types-requests dependency

* Finish fixing mypy errors
* Begin fixing mypy errors

* Add types-requests dependency

* Finish fixing mypy errors
@austind austind changed the title Develop Release v1.3.1 Feb 5, 2025
@austind austind merged commit 9f59f4d into main Feb 5, 2025
1 check passed
@austind austind deleted the develop branch February 5, 2025 13:59
Comment on lines +27 to +28
@overload
def retry(func: F) -> F: ...
Copy link
Contributor

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?

Copy link
Owner Author

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!

Copy link
Contributor

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.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

vscode is showing the right return type, what are you seeing?

Copy link
Contributor

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:

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Still works for me, what do you see?

Copy link
Contributor

@gyandeeps-hh gyandeeps-hh Feb 5, 2025

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

Copy link
Contributor

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()

Copy link
Owner Author

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 :)

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants