-
-
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
Fix/pyright unknown #1873
Merged
Merged
Fix/pyright unknown #1873
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
971b8d8
Add more explicit typing to avoid pyright unknown errors
dephiros dbff96a
forward generic params to JSONField
dephiros d8d5467
Forward generic type to alias for _DisplayT
dephiros 832e52a
update method_decorator#decorator to the correct type
dephiros ff0f4f8
correctly pass typevar for CacheHandler
dephiros faa4866
Add default type for JSONField
dephiros 072433b
fix type_extension import
dephiros 10de619
Address comment about not able to use generic type alias
dephiros 1d5e94a
address comment about generic _T(_ViewType)
dephiros 415d22b
change get_model back to return Type[Any]
dephiros 248eb88
Address feedback to use Typevar for admin_view
dephiros c19f72c
Merge branch 'master' into fix/pyright-unknown
dephiros 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
from collections.abc import Callable, Iterable | ||
from typing import TypeVar | ||
from typing import Any, TypeVar | ||
|
||
from django.http.response import HttpResponseBase | ||
from django.utils.deprecation import MiddlewareMixin | ||
from django.views.generic.base import View | ||
from typing_extensions import TypeAlias | ||
|
||
_T = TypeVar("_T", bound=View | Callable) # Any callable | ||
_CallableType = TypeVar("_CallableType", bound=Callable) | ||
_ViewType = TypeVar("_ViewType", bound=View | Callable[..., Any]) # Any callable | ||
_CallableType = TypeVar("_CallableType", bound=Callable[..., Any]) | ||
_DECORATOR: TypeAlias = Callable[..., Callable[..., HttpResponseBase] | Callable[..., Callable[..., HttpResponseBase]]] | ||
|
||
classonlymethod = classmethod | ||
|
||
def method_decorator(decorator: Callable | Iterable[Callable], name: str = ...) -> Callable[[_T], _T]: ... | ||
def decorator_from_middleware_with_args(middleware_class: type) -> Callable: ... | ||
def decorator_from_middleware(middleware_class: type) -> Callable: ... | ||
def make_middleware_decorator(middleware_class: type[MiddlewareMixin]) -> Callable: ... | ||
def method_decorator( | ||
decorator: _DECORATOR | Iterable[_DECORATOR], name: str = ... | ||
) -> Callable[[_ViewType], _ViewType]: ... | ||
def decorator_from_middleware_with_args(middleware_class: type) -> _DECORATOR: ... | ||
def decorator_from_middleware(middleware_class: type) -> _DECORATOR: ... | ||
def make_middleware_decorator(middleware_class: type[MiddlewareMixin]) -> _DECORATOR: ... | ||
def sync_and_async_middleware(func: _CallableType) -> _CallableType: ... | ||
def sync_only_middleware(func: _CallableType) -> _CallableType: ... | ||
def async_only_middleware(func: _CallableType) -> _CallableType: ... |
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.
Hm,
admin_view
looks like a decorator. I think we want to use aTypeVar
to not ruin any function signature using it. e.g.Where
F
could be a variable bound to a callable returning aHttpResponse