-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
capfirst
annotation does not appear usable -- or probably anything using _StrOrPromiseT
#1626
Comments
Thank you for the clear bug report. I'm a little surprised by Mypy's behaviour here but I guess it has some logic. A PR would be very welcome. It looks like all the functions in |
It's pretty surprising to me that
Explanation from the original PR #689 (comment)
Now this implementation detail is leaking out. I don't understand how subclassing @PIG208 as the author of StrPromise logic, any thoughts? Can't we just remove |
I had not checked that. Wow, that's confusing... I would also expect we can remove |
Offtopic but maybe helpful. Add # Instead of this:
if TYPE_CHECKING:
from django.utils.functional import _StrPromise
# Use this:
from django_stubs_ext import StrPromise |
I think this is a fine fix. |
it looks like this may have magically fixed with the new mypy inference? |
Thanks for the update. The given test case seems to be fixed in mypy 1.7.0 even with But regardless, we should still remove |
Bug report
it appears that the
_StrOrPromiseT
incapfirst
decays toSequence[str]
-- probably because mypy infers the union ofstr | _StrPromise
to beSequence[str]
(becausestr
is also aSequence[str]
)What's wrong
the original error comes from this line -- though I've isolated the bug to a standalone script: https://github.com/getsentry/sentry/blob/c19f762c70afa9145efb10e8a524498316dcea4e/src/sentry/web/forms/accounts.py#L79
here's the standalone version:
How is that should be
if I change this instead to an overload it appears to work correctly:
let me know if you'd be interested in a patch for this or if there's some other ideas on how to fix this
System information
python
version: 3.8.16django
version: (old, lol)mypy
version: 1.4.1django-stubs
version: 4.2.3django-stubs-ext
version: 4.2.2The text was updated successfully, but these errors were encountered: