Skip to content

Commit

Permalink
fix: Fix override_settings decorator typing (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlehoux authored Jan 13, 2023
1 parent 1c482dc commit 6d883cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django-stubs/test/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ from typing_extensions import SupportsIndex, TypeAlias
_TestClass: TypeAlias = type[SimpleTestCase]

_DecoratedTest: TypeAlias = Callable | _TestClass
_DT = TypeVar("_DT", bound=_DecoratedTest)
_C = TypeVar("_C", bound=Callable) # Any callable

TZ_SUPPORT: bool
Expand Down Expand Up @@ -57,7 +58,7 @@ class TestContextDecorator:
) -> None: ...
def decorate_class(self, cls: _TestClass) -> _TestClass: ...
def decorate_callable(self, func: _C) -> _C: ...
def __call__(self, decorated: _DecoratedTest) -> Any: ...
def __call__(self, decorated: _DT) -> _DT: ...

class override_settings(TestContextDecorator):
options: dict[str, Any]
Expand Down
8 changes: 8 additions & 0 deletions tests/typecheck/test/test_utils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- case: override_settings
main: |
from django.test import override_settings
from django.conf import settings
@override_settings(FOO='bar')
def test() -> None:
pass
reveal_type(test) # N: Revealed type is "def ()"

0 comments on commit 6d883cd

Please sign in to comment.