Skip to content

Commit ed7d978

Browse files
authored
Add StepValueValidator, fix argument for SRIDCacheEntry/EmailValidator, improve urls.resolvers types (#1589)
* fix: wrong argument order for SRIDCacheEntry * fix: remove legacy arguments for EmailValidator * feat: add missing validator * fix: misc urls.resolvers types * chore: update allowlist-todo
1 parent f007b6b commit ed7d978

File tree

4 files changed

+11
-25
lines changed

4 files changed

+11
-25
lines changed

django-stubs/contrib/gis/db/models/fields.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ _GT = TypeVar("_GT")
2525
class SRIDCacheEntry(NamedTuple):
2626
units: Any
2727
units_name: str
28-
geodetic: bool
2928
spheroid: str
29+
geodetic: bool
3030

3131
def get_srid_info(srid: int, connection: Any) -> SRIDCacheEntry: ...
3232

django-stubs/core/validators.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ class EmailValidator:
5757
message: _StrOrPromise | None = ...,
5858
code: str | None = ...,
5959
allowlist: Sequence[str] | None = ...,
60-
*,
61-
whitelist: Sequence[str] | None = ...,
6260
) -> None: ...
63-
@property
64-
def domain_whitelist(self) -> Sequence[str]: ...
65-
@domain_whitelist.setter
66-
def domain_whitelist(self, allowlist: Sequence[str]) -> None: ...
6761
def __call__(self, value: str | None) -> None: ...
6862
def validate_domain_part(self, domain_part: str) -> bool: ...
6963
def __eq__(self, other: object) -> bool: ...
@@ -100,6 +94,7 @@ class BaseValidator:
10094

10195
class MaxValueValidator(BaseValidator): ...
10296
class MinValueValidator(BaseValidator): ...
97+
class StepValueValidator(BaseValidator): ...
10398

10499
class MinLengthValidator(BaseValidator):
105100
def clean(self, x: Sized) -> int: ...

django-stubs/urls/resolvers.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from django.core.checks.messages import CheckMessage
77
from django.urls import _AnyURL
88
from django.urls.converters import UUIDConverter
99
from django.utils.datastructures import MultiValueDict
10+
from django.utils.functional import cached_property
1011
from typing_extensions import TypeAlias
1112

1213
class ResolverMatch:
@@ -32,6 +33,8 @@ class ResolverMatch:
3233
namespaces: list[str | None] | None = ...,
3334
route: str | None = ...,
3435
tried: Any | None = ...,
36+
captured_kwargs: dict[str, Any] | None = ...,
37+
extra_kwargs: dict[str, Any] | None = ...,
3538
) -> None: ...
3639
def __getitem__(self, index: int) -> Any: ...
3740
# for tuple unpacking
@@ -95,7 +98,7 @@ class URLPattern:
9598
) -> None: ...
9699
def check(self) -> list[CheckMessage]: ...
97100
def resolve(self, path: str) -> ResolverMatch | None: ...
98-
@property
101+
@cached_property
99102
def lookup_str(self) -> str: ...
100103

101104
class URLResolver:
@@ -121,12 +124,13 @@ class URLResolver:
121124
def namespace_dict(self) -> dict[str, tuple[str, URLResolver]]: ...
122125
@property
123126
def app_dict(self) -> dict[str, list[str]]: ...
124-
@property
127+
@cached_property
125128
def urlconf_module(self) -> ModuleType | None | Sequence[_AnyURL]: ...
126-
@property
129+
@cached_property
127130
def url_patterns(self) -> list[_AnyURL]: ...
128131
def resolve(self, path: str) -> ResolverMatch: ...
129132
def resolve_error_handler(self, view_type: int) -> Callable: ...
130133
def reverse(self, lookup_view: str, *args: Any, **kwargs: Any) -> str: ...
131134
def _is_callback(self, name: str) -> bool: ...
132135
def _populate(self) -> None: ...
136+
def check(self) -> list[CheckMessage]: ...

scripts/stubtest/allowlist_todo.txt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ django.contrib.gis.db.models.aggregates.GeoAggregate.output_field
496496
django.contrib.gis.db.models.fields.BaseSpatialField.class_lookups
497497
django.contrib.gis.db.models.fields.GeometryField.contribute_to_class
498498
django.contrib.gis.db.models.fields.RasterField.contribute_to_class
499-
django.contrib.gis.db.models.fields.SRIDCacheEntry.__match_args__
500-
django.contrib.gis.db.models.fields.SRIDCacheEntry.__new__
501499
django.contrib.gis.db.models.functions.Area.as_sql
502500
django.contrib.gis.db.models.functions.GeoFuncMixin.__init__
503501
django.contrib.gis.db.models.functions.GeoFuncMixin.as_sql
@@ -982,11 +980,9 @@ django.core.validators.BaseValidator.__new__
982980
django.core.validators.BaseValidator.deconstruct
983981
django.core.validators.DecimalValidator.__new__
984982
django.core.validators.DecimalValidator.deconstruct
985-
django.core.validators.EmailValidator.__init__
986983
django.core.validators.EmailValidator.__new__
987984
django.core.validators.EmailValidator.deconstruct
988985
django.core.validators.EmailValidator.domain_regex
989-
django.core.validators.EmailValidator.domain_whitelist
990986
django.core.validators.EmailValidator.literal_regex
991987
django.core.validators.EmailValidator.user_regex
992988
django.core.validators.FileExtensionValidator.__new__
@@ -1003,7 +999,8 @@ django.core.validators.ProhibitNullCharactersValidator.__new__
1003999
django.core.validators.ProhibitNullCharactersValidator.deconstruct
10041000
django.core.validators.RegexValidator.__new__
10051001
django.core.validators.RegexValidator.deconstruct
1006-
django.core.validators.StepValueValidator
1002+
django.core.validators.StepValueValidator.__new__
1003+
django.core.validators.StepValueValidator.deconstruct
10071004
django.core.validators.URLValidator.__new__
10081005
django.core.validators.URLValidator.deconstruct
10091006
django.core.validators.URLValidator.regex
@@ -2405,20 +2402,10 @@ django.test.testcases._AssertTemplateUsedContext.message
24052402
django.test.utils.TimeKeeperProtocol
24062403
django.test.utils.override_settings.enable_exception
24072404
django.test.utils.setup_databases
2408-
django.urls.ResolverMatch.__init__
24092405
django.urls.ResolverMatch.__iter__
2410-
django.urls.URLPattern.lookup_str
2411-
django.urls.URLResolver.check
2412-
django.urls.URLResolver.url_patterns
2413-
django.urls.URLResolver.urlconf_module
24142406
django.urls.conf.path
24152407
django.urls.conf.re_path
24162408
django.urls.path
24172409
django.urls.re_path
24182410
django.urls.resolvers.LocaleRegexDescriptor.__get__
2419-
django.urls.resolvers.ResolverMatch.__init__
24202411
django.urls.resolvers.ResolverMatch.__iter__
2421-
django.urls.resolvers.URLPattern.lookup_str
2422-
django.urls.resolvers.URLResolver.check
2423-
django.urls.resolvers.URLResolver.url_patterns
2424-
django.urls.resolvers.URLResolver.urlconf_module

0 commit comments

Comments
 (0)