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

Improve APIException input and detail types #387

Merged

Conversation

intgr
Copy link
Contributor

@intgr intgr commented Mar 30, 2023

APIException and its subclasses are more liberal in what they accept as input, but their detail attribute is already converted to a stricter type: translation strings are resolved, strings are conveted to ErrorDetail, etc

This uses the recursive types feature from mypy and thus bumps minimum mypy version to 0.991: https://mypy-lang.blogspot.com/2022/11/mypy-0990-released.html

@intgr
Copy link
Contributor Author

intgr commented Mar 30, 2023

  • I'm planning to do some more validation still, but I think this is more or less correct.

@intgr intgr force-pushed the precise-exception-input-detail-types branch from 9b57424 to 631fc4c Compare March 31, 2023 14:53
APIException and its subclasses are more liberal in what they accept as input, but their `detail` attribute is already converted to a stricter type: translation strings are resolved, strings are conveted to ErrorDetail, etc

This uses the recursive types feature from mypy and thus bumps minimum mypy version to 0.991: https://mypy-lang.blogspot.com/2022/11/mypy-0990-released.html
@intgr intgr force-pushed the precise-exception-input-detail-types branch from ca39db7 to a77a05e Compare April 7, 2023 11:13
@intgr intgr added the help wanted Extra attention is needed label Apr 7, 2023
@intgr
Copy link
Contributor Author

intgr commented Apr 7, 2023

I think this is complete. Reviews welcome.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

The usage seems correct to me, but I am not an expert in this API :(

@intgr intgr merged commit 7660f0e into typeddjango:master Apr 20, 2023
16 checks passed
@intgr intgr deleted the precise-exception-input-detail-types branch June 27, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Development

Successfully merging this pull request may close these issues.

None yet

2 participants