Skip to content

Commit 4017cec

Browse files
ngnpopesobolevn
authored andcommitted
Add support for mypy v1.16 (typeddjango#2703)
Co-authored-by: sobolevn <[email protected]>
1 parent 6e1a5e6 commit 4017cec

File tree

16 files changed

+75
-358
lines changed

16 files changed

+75
-358
lines changed
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
from typing import Any
2-
31
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
42
from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures
5-
from django.utils.functional import cached_property
63

74
class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
85
supports_add_srs_entry: bool
96
supports_geometry_field_introspection: bool
107
supports_geometry_field_unique_index: bool
118
supports_perimeter_geodetic: bool
129
supports_dwithin_distance_expr: bool
13-
@cached_property
14-
def django_test_skips(self) -> dict[str, Any]: ... # type: ignore[override]

django-stubs/db/backends/postgresql/features.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class DatabaseFeatures(BaseDatabaseFeatures):
4545
has_json_operators: bool
4646
json_key_contains_list_matching_requires_list: bool
4747
@property
48-
def is_postgresql_14(self) -> bool: ...
49-
@property
5048
def is_postgresql_15(self) -> bool: ...
5149
@cached_property
5250
def is_postgresql_16(self) -> bool: ...
51+
@property
52+
def is_postgresql_17(self) -> bool: ...
5353
has_brin_autosummarize: bool
5454
has_websearch_to_tsquery: bool
5555
supports_table_partitions: bool

django-stubs/db/models/fields/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
130130
model: type[Model]
131131
name: str
132132
verbose_name: _StrOrPromise
133-
description: str | _Getter[str]
133+
description: _StrOrPromise | _Getter[_StrOrPromise]
134134
blank: bool
135135
null: bool
136136
unique: bool

django-stubs/utils/datastructures.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ class MultiValueDict(dict[_K, _V]):
6262
def __init__(self, key_to_list_mapping: Mapping[_K, list[_V] | None]) -> None: ...
6363
@overload
6464
def __init__(self, key_to_list_mapping: Iterable[tuple[_K, list[_V]]] = ()) -> None: ...
65+
@overload # type: ignore[override]
66+
def get(self, key: _K, default: None = None) -> _V | None: ...
6567
@overload
66-
def get(self, key: _K) -> _V | None: ...
68+
def get(self, key: _K, default: _V) -> _V: ...
6769
@overload
6870
def get(self, key: _K, default: _Z) -> _V | _Z: ...
6971
def getlist(self, key: _K, default: _Z | None = None) -> list[_V] | _Z: ...

django-stubs/utils/functional.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class classproperty(Generic[_Get]):
9797

9898
@type_check_only
9999
class _Getter(Protocol[_Get]): # noqa: PYI046
100-
"""Type fake to declare some read-only properties (until `property` builtin is generic)
100+
"""
101+
Type fake to declare some read-only properties (until `property` builtin is generic).
101102
102103
We can use something like `Union[_Getter[str], str]` in base class to avoid errors
103104
when redefining attribute with property or property with attribute.

ext/django_stubs_ext/db/models/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class TypedModelMeta:
3636
required_db_vendor: ClassVar[Literal["sqlite", "postgresql", "mysql", "oracle"]]
3737
select_on_save: ClassVar[bool] # default: False
3838
indexes: ClassVar[_ListOrTuple[Index]]
39-
unique_together: ClassVar[Sequence[Sequence[str]] | Sequence[str]]
40-
index_together: ClassVar[Sequence[Sequence[str]] | Sequence[str]] # Deprecated in Django 4.2
39+
unique_together: ClassVar[Sequence[Sequence[str]]]
40+
index_together: ClassVar[Sequence[Sequence[str]]] # Deprecated in Django 4.2
4141
constraints: ClassVar[_ListOrTuple[BaseConstraint]]
4242
verbose_name: ClassVar[StrOrPromise]
4343
verbose_name_plural: ClassVar[StrOrPromise]

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies = [
4141
]
4242

4343
[project.optional-dependencies]
44-
compatible-mypy = ["mypy>=1.13,<1.16"]
44+
compatible-mypy = ["mypy>=1.13,<1.17"]
4545
oracle = ["oracledb"]
4646
redis = ["redis", "types-redis"]
4747

@@ -59,7 +59,7 @@ tests = [
5959
"jinja2==3.1.6",
6060
"pyyaml==6.0.2",
6161
# typing:
62-
"mypy==1.15.0",
62+
"mypy==1.16.0",
6363
"django-stubs[compatible-mypy,oracle,redis]",
6464
]
6565
pyright = ["pyright==1.1.401"]

scripts/stubtest/allowlist.txt

Lines changed: 6 additions & 296 deletions
Large diffs are not rendered by default.

scripts/stubtest/allowlist_todo.txt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ django.contrib.gis.db.models.JSONField.get_transform
244244
django.contrib.gis.db.models.Lookup.get_prep_lhs
245245
django.contrib.gis.db.models.Lookup.allowed_default
246246
django.contrib.gis.db.models.Lookup.lookup_name
247-
django.contrib.gis.db.models.Lookup.output_field
248247
django.contrib.gis.db.models.ManyToManyField.__get__
249248
django.contrib.gis.db.models.ManyToManyField.formfield
250249
django.contrib.gis.db.models.ManyToManyField.path_infos
@@ -414,14 +413,7 @@ django.core.management.commands.makemessages.TranslatableFile.path
414413
django.core.servers.basehttp.ServerHandler.__init__
415414
django.core.servers.basehttp.ThreadedWSGIServer.__init__
416415
django.db.backends.ddl_references.Expressions
417-
django.db.backends.mysql.base.DatabaseWrapper.data_type_check_constraints
418-
django.db.backends.mysql.base.DatabaseWrapper.display_name
419-
django.db.backends.mysql.base.DatabaseWrapper.mysql_is_mariadb
420-
django.db.backends.mysql.base.DatabaseWrapper.mysql_server_data
421-
django.db.backends.mysql.base.DatabaseWrapper.mysql_server_info
422-
django.db.backends.mysql.base.DatabaseWrapper.mysql_version
423416
django.db.backends.mysql.base.DatabaseWrapper.ops
424-
django.db.backends.mysql.base.DatabaseWrapper.sql_mode
425417
django.db.backends.mysql.features.DatabaseFeatures.can_rename_index
426418
django.db.backends.mysql.features.DatabaseFeatures.can_return_rows_from_bulk_insert
427419
django.db.backends.mysql.features.DatabaseFeatures.django_test_skips
@@ -437,8 +429,10 @@ django.db.backends.mysql.introspection.InfoLine._fields
437429
django.db.backends.mysql.introspection.InfoLine.comment
438430
django.db.backends.mysql.introspection.TableInfo
439431
django.db.backends.mysql.schema.DatabaseSchemaEditor.sql_alter_column_comment
432+
django.db.backends.oracle.features.DatabaseFeatures.django_test_skips
440433
django.db.backends.oracle.features.DatabaseFeatures.introspected_field_types
441434
django.db.backends.oracle.features.DatabaseFeatures.supports_collation_on_charfield
435+
django.db.backends.oracle.features.DatabaseFeatures.supports_frame_exclusion
442436
django.db.backends.postgresql.base.DatabaseWrapper.Database
443437
django.db.backends.postgresql.base.DatabaseWrapper.ops
444438
django.db.backends.postgresql.base.DatabaseWrapper.tzinfo_factory
@@ -595,7 +589,6 @@ django.db.models.JSONField.get_transform
595589
django.db.models.Lookup.get_prep_lhs
596590
django.db.models.Lookup.lookup_name
597591
django.db.models.Lookup.allowed_default
598-
django.db.models.Lookup.output_field
599592
django.db.models.ManyToManyField.__get__
600593
django.db.models.ManyToManyField.formfield
601594
django.db.models.ManyToManyField.path_infos
@@ -870,7 +863,6 @@ django.db.models.lookups.IExact.process_rhs
870863
django.db.models.lookups.Lookup.get_prep_lhs
871864
django.db.models.lookups.Lookup.allowed_default
872865
django.db.models.lookups.Lookup.lookup_name
873-
django.db.models.lookups.Lookup.output_field
874866
django.db.models.lookups.PatternLookup.process_rhs
875867
django.db.models.query.EmptyQuerySet.__init__
876868
django.db.models.query.QuerySet.__deepcopy__
@@ -909,7 +901,6 @@ django.db.models.sql.where.WhereNode.get_group_by_cols
909901
django.db.models.sql.where.WhereNode.get_lookup
910902
django.db.models.sql.where.WhereNode.get_source_expressions
911903
django.db.models.sql.where.WhereNode.leaves
912-
django.db.models.sql.where.WhereNode.output_field
913904
django.db.models.sql.where.WhereNode.replace_expressions
914905
django.db.models.sql.where.WhereNode.set_source_expressions
915906
django.db.models.sql.where.WhereNode.split_having

scripts/stubtest/allowlist_todo_django52.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ django.db.backends.postgresql.base.DatabaseWrapper.close_pool
6868
django.db.backends.postgresql.base.DatabaseWrapper.pool
6969
django.db.backends.postgresql.compiler
7070
django.db.backends.postgresql.features.DatabaseFeatures.django_test_skips
71-
django.db.backends.postgresql.features.DatabaseFeatures.is_postgresql_17
7271
django.db.backends.postgresql.features.DatabaseFeatures.supports_nulls_distinct_unique_constraints
7372
django.db.backends.postgresql.psycopg_any
7473
django.db.backends.sqlite3.base.DatabaseWrapper.transaction_modes

0 commit comments

Comments
 (0)