-
Notifications
You must be signed in to change notification settings - Fork 312
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
Money
class instantiation returns Any
as type
#674
Comments
Digging into this further the issue is caused by the |
@alex-way Note that django-money does not yet expose type hints. py-moneyed received support for type hints in v2.0 and support for that was only recently merged: #638 Because that is now merged, there should be no blockers to adding type hints and exposing them with the It sounds like an interesting find with the deconstructable decorator. Does django-stubs have proper typing for it? E.g. should be something like |
Btw, unlocking the possibility to add type hints was the entire point of me pushing for the py-moneyed 2.0 upgrade here ;) |
As a workaround I've done something which I don't advise as it can cause issues with type hinting for other objects. However, it seems to work for my use case. I created a file in the root of my repo from typing import Any, Optional, Type
from djmoney.money import Money
# override for typehint
def deconstructible(*args: Any, path: Optional[Any] = ...) -> Type[Money]: ... Again I'm not advocating for this solution, but just putting it out there for others who need a quick fix. |
I just opened a merge request for this exact problem: typeddjango/django-stubs#1116 |
When instantianting the djmoney.money.Money class it hints the type as
Any
when it should beMoney
. This prevents my code editor from presenting autocomplete suggestions as the type can't be inferred.The text was updated successfully, but these errors were encountered: