-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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: fix mypy errors in wladmin module. Rel: #3703 #12690
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
from django.utils.translation import gettext, gettext_lazy | ||
|
||
if TYPE_CHECKING: | ||
from weblate.auth.models import AuthenticatedHttpRequest | ||
from django.http import HttpRequest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intention here is that Django's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this is an upstream recommended approach: https://github.com/typeddjango/django-stubs?tab=readme-ov-file#how-can-i-create-a-httprequest-thats-guaranteed-to-have-an-authenticated-user |
||
|
||
|
||
class WeblateAdminSite(AdminSite): | ||
|
@@ -38,7 +38,7 @@ def site_url(self): | |
return settings.URL_PREFIX | ||
return "/" | ||
|
||
def each_context(self, request: AuthenticatedHttpRequest): | ||
def each_context(self, request: HttpRequest): | ||
from weblate.wladmin.models import ConfigurationError | ||
|
||
result = super().each_context(request) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I'd overlooked this one. I've tried to investigate a bit but couldn't find a working solution, just this issue ticket typeddjango/django-stubs#1067 or
#type: ignore[assignment]
or usingcast
(which seems too brutal)Should I remove this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably yes. I think this is best to be addressed at django-stubs or mypy, otherwise we end up doing that on every model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Furthermore, this does address only accessing query set via
.objects
but not when using related manager.