-
-
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
Allow returning Response from admin @action callbacks #1331
Merged
intgr
merged 13 commits into
typeddjango:master
from
christianbundy:christian/fix-action-return-type
Jan 25, 2023
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
31ef26e
Fix admin action return type
christianbundy c089372
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3fe1a91
Use HttpResponseBase to support StreamingHttpResponse
christianbundy 5bc0daa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a71a424
Fix usage
christianbundy 50ed1fe
Merge branch 'master' of github.com:typeddjango/django-stubs into chr…
christianbundy aa9dea3
Fix issues
christianbundy 92da2c1
Fix test
christianbundy d004b1b
Remove redundant comma
christianbundy 3fa57f0
Use `T | None` rather than `Optional[T]`
christianbundy 66e29c9
Add freestanding actions to test
christianbundy 0477a26
Add negative test cases
christianbundy ea49719
Add unhappier paths and fix problems
christianbundy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
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.
I think there was a good reason why these
Callable[...]
were duplicated before at each overload.I'm not sure why exactly -- maybe mypy doesn't support TypeVars inside TypeVars -- but after your changes, this no longer raises an error with mypy at the location of the decorator:
I suppose this logic could also use a few negative test cases -- checking that mypy correctly flags incorrect usage of the parameters or return types.
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,
TypeVar
can't be bound to aTypeAlias
, it'll resolve toAny
before it's matched with generic arguments of a class or a callable.A few non-happy test cases should make that obvious.
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.
Sounds good, I've reverted the previous change and added more tests to highlight this issue. I've left
_DisplayCallableT
alone, but I'd imagine it probably has a similar problem.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.
I see… Yes, if it's a problem, then the equivalent for display is also surely broken.
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.
I wonder whether it'd be worthwhile to enable
disallow_any_generics
for this repo -- I put together a quick repro, and it looks like if we enable the rule we'll get warnings for this: https://mypy-play.net/?mypy=latest&python=3.11&flags=disallow-any-generics&gist=bf198a38181d36c2105ce3fef468d702There 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.
Yeah, maybe, but best looked into separately later.
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.
I'm afraid the fallout from
disallow_any_generics
will be enormous. But I may be wrong :)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.
You aren't wrong. 😬 Here's a quick stab at it though: #1339