-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Allow None
as redirect_field_name value for user_passes_test
and login_required
#1600
Merged
sobolevn
merged 1 commit into
typeddjango:master
from
JoeHitchen:redirect_field_name_nones
Jun 28, 2023
Merged
Allow None
as redirect_field_name value for user_passes_test
and login_required
#1600
sobolevn
merged 1 commit into
typeddjango:master
from
JoeHitchen:redirect_field_name_nones
Jun 28, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…`login_required`
sobolevn
approved these changes
Jun 28, 2023
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.
Yes, you are right.
- Source: https://github.com/django/django/blob/21e686471598d6c755d93a570de20dc00d8d27f6/django/contrib/auth/views.py#L186
- We already have
redirect_field_name
annotated asOptional
:django-stubs/django-stubs/contrib/auth/views.pyi
Lines 32 to 34 in 8c08d35
def redirect_to_login( next: str, login_url: str | None = ..., redirect_field_name: str | None = ... ) -> HttpResponseRedirect: ...
Cheers! |
descope bot
referenced
this pull request
in descope/django-descope
Jul 20, 2023
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [django-stubs](https://github.com/typeddjango/django-stubs) ([changelog](https://github.com/typeddjango/django-stubs/releases)) | dev | patch | `4.2.2` -> `4.2.3` | --- ### Release Notes <details> <summary>typeddjango/django-stubs (django-stubs)</summary> ### [`v4.2.3`](https://github.com/typeddjango/django-stubs/releases/tag/4.2.3) [Compare Source](https://github.com/typeddjango/django-stubs/compare/4.2.2...4.2.3) This version fixes two regressions in previons `django-stubs` release and also a few other fixes and improvements. Special thanks to [@​GabDug](https://github.com/GabDug) for contributing regression fixes on a short order. This time there is no corresponding release of `django-stubs-ext`. ##### Stubs fixes - Fixed type error when subclassing `AppConfig` and assigning string to `default_auto_field` by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1596](https://github.com/typeddjango/django-stubs/pull/1596) - Fixed type error when subclassing `MiddlewareMixin.__call__()` and using `return self.get_response()` by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1595](https://github.com/typeddjango/django-stubs/pull/1595) - Allow `None` as `redirect_field_name` value for `@user_passes_test` and `@login_required` decorators by [@​JoeHitchen](https://github.com/JoeHitchen) in [https://github.com/typeddjango/django-stubs/pull/1600](https://github.com/typeddjango/django-stubs/pull/1600) ##### Plugin fixes - Fixed long-standing issue with `Date(Time)Field` when using mypy setting `disallow_any_explicit` by [@​sobolevn](https://github.com/sobolevn) in [https://github.com/typeddjango/django-stubs/pull/1599](https://github.com/typeddjango/django-stubs/pull/1599) ##### Stubs changes - Added `BigIntegerField.MAX_BIGINT` attribute by [@​asottile](https://github.com/asottile) in [https://github.com/typeddjango/django-stubs/pull/1598](https://github.com/typeddjango/django-stubs/pull/1598) - Improved Jinja2 types and updated `pytest-mypy-plugins` by [@​sobolevn](https://github.com/sobolevn) in [https://github.com/typeddjango/django-stubs/pull/1601](https://github.com/typeddjango/django-stubs/pull/1601) ##### CI/Testing - Run tests in multiple shards and all Python versions by [@​sobolevn](https://github.com/sobolevn) in [https://github.com/typeddjango/django-stubs/pull/1603](https://github.com/typeddjango/django-stubs/pull/1603) ##### Housekeeping - Converted `_typeshed.Self` usages to `typing_extensions.Self` (PEP 673) by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1591](https://github.com/typeddjango/django-stubs/pull/1591) - Version 4.2.3 release (django-stubs only) by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1604](https://github.com/typeddjango/django-stubs/pull/1604) #### New Contributors - [@​JoeHitchen](https://github.com/JoeHitchen) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1600](https://github.com/typeddjango/django-stubs/pull/1600) **Full Changelog**: typeddjango/django-stubs@4.2.2...4.2.3 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xLjExIiwidXBkYXRlZEluVmVyIjoiMzYuMS4xMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the Django documentation, the
redirect_field_name
argument touser_passes_test
acceptsNone
as a value as well as a string, but Django Stubs currently only recognises strings as acceptable values. Specifically, passing aNone
indicates that the redirect field should be omitted.The documentation does not explicitly state whether
redirect_field_name
oflogin_required
allows or does not allowNone
values, but my own usage indicates that it does and it behaves in the same way.I haven't attempted to make this change globally for all instances of
redirect_field_name
since I'm not familiar with all their usages, but note that some cases already allowNone
s while others that still won't.pytest
runs with 31 failures (344 passes), however this is the same as I get onmaster
stubtest.sh
There is not an open issue related to this as far as I am aware - I noticed the problem and since it was a simple solution I went straight to fixing.