File tree Expand file tree Collapse file tree 2 files changed +38
-29
lines changed Expand file tree Collapse file tree 2 files changed +38
-29
lines changed Original file line number Diff line number Diff line change 1+ from django .apps .config import AppConfig
2+ from django .utils .functional import cached_property
3+ from typing_extensions import assert_type
4+
5+
6+ class FooConfig (AppConfig ):
7+ name = "foo"
8+ default_auto_field = "django.db.models.BigAutoField"
9+
10+
11+ class BarConfig (AppConfig ):
12+ name = "foo"
13+
14+ @property
15+ def default_auto_field (self ) -> str : # type: ignore[override]
16+ return "django.db.models.BigAutoField"
17+
18+
19+ class BazConfig (AppConfig ):
20+ name = "foo"
21+
22+ @cached_property
23+ def default_auto_field (self ) -> str : # type: ignore[override]
24+ return "django.db.models.BigAutoField"
25+
26+
27+ class FooBarConfig (AppConfig ):
28+ name = "foo"
29+ default_auto_field = cached_property (lambda self : "django.db.models.BigAutoField" )
30+
31+
32+ # Pyright correctly picks up our fake '_Getter' descriptor on class level. But we
33+ # silence the pyright error since mypy doesn't follow along and the fake descriptor
34+ # is a stubs detail made to round other problems.
35+ assert_type (FooConfig .default_auto_field , str ) # pyright: ignore[reportAssertTypeFailure]
36+ assert_type (BarConfig ("bar" , None ).default_auto_field , str )
37+ assert_type (BazConfig ("baz" , None ).default_auto_field , str )
38+ assert_type (FooBarConfig ("baz" , None ).default_auto_field , str )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments