-
Notifications
You must be signed in to change notification settings - Fork 11
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
Mypy: improve type hints #74
Closed
Labels
bug
Something isn't working
Comments
Hi @Merinorus Thanks a lot for your time and fix. Of course, I will review it soon and this fix will be in the next release |
Merinorus
added a commit
to Merinorus/pydantic-i18n
that referenced
this issue
Feb 12, 2023
Hi @Merinorus This issue was fixed in #88 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Hello!
The
translate
function returns aDict[str, Any]
.When using the result of a translation, I want to read the
loc
attribute.Eg:
error.get("loc")
But it leads to a Mypy error:
Value of type "Optional[Any]" is not indexable
.To correct this, I use the
ErrorDict
type included in the pydantic lib, to improve type checking. If we look at the pydantic source code, we get:which is an equivalent of:
Proposal
Instead of returning a
Dict[str, Any]
, thetranslate
function should return a pydanticErrorDict
.Environment
The text was updated successfully, but these errors were encountered: