From aca3fb22be89549de828213e8d896bc8fdcf0ef9 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 23 Dec 2024 15:43:43 +0300 Subject: [PATCH 1/6] Update mypy to 1.14 --- django-stubs/db/models/enums.pyi | 12 ++++++------ requirements.txt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/django-stubs/db/models/enums.pyi b/django-stubs/db/models/enums.pyi index a13dc7c81..e511a4f01 100644 --- a/django-stubs/db/models/enums.pyi +++ b/django-stubs/db/models/enums.pyi @@ -17,9 +17,9 @@ else: _enum_property = property EnumType = enum.EnumMeta - class ReprEnum(enum.Enum): ... - class IntEnum(int, ReprEnum): ... - class StrEnum(str, ReprEnum): ... + class ReprEnum(enum.Enum): ... # type: ignore[misc] + class IntEnum(int, ReprEnum): ... # type: ignore[misc] + class StrEnum(str, ReprEnum): ... # type: ignore[misc] @deprecated("ChoicesMeta is deprecated in favor of ChoicesType and will be removed in Django 6.0.") class ChoicesMeta(EnumType): @@ -42,7 +42,7 @@ class ChoicesMeta(EnumType): ChoicesType: TypeAlias = ChoicesMeta -class Choices(enum.Enum, metaclass=ChoicesType): +class Choices(enum.Enum, metaclass=ChoicesType): # type: ignore[misc] @property def label(self) -> str: ... @_enum_property @@ -61,7 +61,7 @@ class _IntegerChoicesMeta(ChoicesType): # In reality, the `__init__` overloads provided below should also support # all the arguments of `int.__new__`/`str.__new__` (e.g. `base`, `encoding`). # They are omitted on purpose to avoid having convoluted stubs for these enums: -class IntegerChoices(Choices, IntEnum, metaclass=_IntegerChoicesMeta): +class IntegerChoices(Choices, IntEnum, metaclass=_IntegerChoicesMeta): # type: ignore[misc] @overload def __init__(self, x: ConvertibleToInt) -> None: ... @overload @@ -77,7 +77,7 @@ class _TextChoicesMeta(ChoicesType): @property def values(self) -> list[str]: ... -class TextChoices(Choices, StrEnum, metaclass=_TextChoicesMeta): +class TextChoices(Choices, StrEnum, metaclass=_TextChoicesMeta): # type: ignore[misc] @overload def __init__(self, object: str) -> None: ... @overload diff --git a/requirements.txt b/requirements.txt index 9f300e3fa..df6c714eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,5 +12,5 @@ Django==5.1.4; python_version >= '3.10' -e .[redis,compatible-mypy,oracle] # Overrides: -mypy==1.13.0 +mypy==1.14.0 pyright==1.1.391 From ce9a0f7fad8d1fc2dbc2b02c33e887d6bdc7edb8 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 23 Dec 2024 15:45:03 +0300 Subject: [PATCH 2/6] Update mypy to 1.14 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 37c046639..395e2947e 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def find_stub_files(name: str) -> list[str]: # Keep compatible-mypy major.minor version pinned to what we use in CI (requirements.txt) extras_require = { - "compatible-mypy": ["mypy>=1.12,<1.14"], + "compatible-mypy": ["mypy>=1.12,<1.15"], "redis": ["redis"], "oracle": ["oracledb"], } From 429f5554f02e8ffd5644bf3fbea2c27311e571e8 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 23 Dec 2024 15:50:37 +0300 Subject: [PATCH 3/6] Generate allowlist --- scripts/stubtest.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/stubtest.sh b/scripts/stubtest.sh index 4167f339c..5fe99ba4e 100644 --- a/scripts/stubtest.sh +++ b/scripts/stubtest.sh @@ -15,4 +15,5 @@ stubtest django \ --ignore-positional-only \ --allowlist scripts/stubtest/allowlist.txt \ --allowlist scripts/stubtest/allowlist_todo.txt \ - --allowlist scripts/stubtest/allowlist_todo_django51.txt + --allowlist scripts/stubtest/allowlist_todo_django51.txt \ + --generate-allowlist From 08ce97d72f3e360db136cf2fc04648a357288a5b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 23 Dec 2024 15:52:53 +0300 Subject: [PATCH 4/6] Fix stubtest --- scripts/stubtest.sh | 3 +- scripts/stubtest/allowlist_todo.txt | 72 +++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/scripts/stubtest.sh b/scripts/stubtest.sh index 5fe99ba4e..4167f339c 100644 --- a/scripts/stubtest.sh +++ b/scripts/stubtest.sh @@ -15,5 +15,4 @@ stubtest django \ --ignore-positional-only \ --allowlist scripts/stubtest/allowlist.txt \ --allowlist scripts/stubtest/allowlist_todo.txt \ - --allowlist scripts/stubtest/allowlist_todo_django51.txt \ - --generate-allowlist + --allowlist scripts/stubtest/allowlist_todo_django51.txt diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index 2f295d4b1..24f85454a 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -1302,3 +1302,75 @@ django.db.models.expressions.rhs django.db.models.expressions.result django.db.models.expressions.lhs django.db.backends.postgresql.base.Cursor + +# mypy 1.14.0 new issues: +django.apps.__all__ +django.conf.urls.__all__ +django.contrib.admin.__all__ +django.contrib.gis.admin.__all__ +django.contrib.gis.db.models.__all__ +django.contrib.gis.db.models.aggregates.__all__ +django.contrib.gis.db.models.sql.__all__ +django.contrib.gis.gdal.__all__ +django.contrib.gis.geoip2.__all__ +django.contrib.gis.geos.io.__all__ +django.contrib.gis.geos.prototypes.misc.__all__ +django.contrib.gis.measure.__all__ +django.contrib.gis.sitemaps.__all__ +django.contrib.gis.utils.__all__ +django.contrib.messages.api.__all__ +django.contrib.postgres.aggregates.general.__all__ +django.contrib.postgres.aggregates.statistics.__all__ +django.contrib.postgres.constraints.__all__ +django.contrib.postgres.fields.array.__all__ +django.contrib.postgres.fields.citext.__all__ +django.contrib.postgres.fields.hstore.__all__ +django.contrib.postgres.fields.jsonb.__all__ +django.contrib.postgres.fields.ranges.__all__ +django.contrib.postgres.forms.hstore.__all__ +django.contrib.postgres.forms.ranges.__all__ +django.contrib.postgres.indexes.__all__ +django.core.cache.__all__ +django.core.checks.__all__ +django.core.files.locks.__all__ +django.core.files.move.__all__ +django.core.files.storage.memory.__all__ +django.core.files.temp.__all__ +django.core.files.uploadedfile.__all__ +django.core.files.uploadhandler.__all__ +django.core.mail.__all__ +django.core.servers.basehttp.__all__ +django.db.__all__ +django.db.migrations.operations.__all__ +django.db.models.__all__ +django.db.models.aggregates.__all__ +django.db.models.constraints.__all__ +django.db.models.enums.__all__ +django.db.models.fields.__all__ +django.db.models.fields.generated.__all__ +django.db.models.fields.json.__all__ +django.db.models.functions.__all__ +django.db.models.functions.window.__all__ +django.db.models.indexes.__all__ +django.db.models.sql.__all__ +django.db.models.sql.query.__all__ +django.db.models.sql.subqueries.__all__ +django.forms.boundfield.__all__ +django.forms.fields.__all__ +django.forms.forms.__all__ +django.forms.formsets.__all__ +django.forms.models.__all__ +django.forms.widgets.__all__ +django.http.__all__ +django.http.multipartparser.__all__ +django.template.__all__ +django.test.__all__ +django.test.client.__all__ +django.test.testcases.__all__ +django.test.utils.__all__ +django.urls.__all__ +django.utils.choices.__all__ +django.utils.timezone.__all__ +django.utils.translation.__all__ +django.views.__all__ +django.views.generic.__all__ From fa34d92a11538eb15ca33b8e5b05795a248843e1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 23 Dec 2024 16:01:34 +0300 Subject: [PATCH 5/6] Fix tests --- tests/typecheck/fields/test_base.yml | 2 +- tests/typecheck/managers/test_managers.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/typecheck/fields/test_base.yml b/tests/typecheck/fields/test_base.yml index 42f20966d..40bab2593 100644 --- a/tests/typecheck/fields/test_base.yml +++ b/tests/typecheck/fields/test_base.yml @@ -27,7 +27,7 @@ booking = Booking() reveal_type(booking.id) # N: Revealed type is "builtins.int" reveal_type(booking.time_range) # N: Revealed type is "Any" - reveal_type(booking.some_decimal) # N: Revealed type is "_decimal.Decimal" + reveal_type(booking.some_decimal) # N: Revealed type is "decimal.Decimal" installed_apps: - myapp files: diff --git a/tests/typecheck/managers/test_managers.yml b/tests/typecheck/managers/test_managers.yml index e111ca63c..d1c470331 100644 --- a/tests/typecheck/managers/test_managers.yml +++ b/tests/typecheck/managers/test_managers.yml @@ -680,7 +680,7 @@ installed_apps: - myapp out: | - main:2: note: Revealed type is "myapp.models.MyModel.MyManager" + main:2: note: Revealed type is "myapp.models.MyModel.MyManager[myapp.models.MyModel]" main:3: note: Revealed type is "Any" files: - path: myapp/__init__.py From 8bd6a626decb25129323bda6dba3f75a4cc316c6 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 23 Dec 2024 16:06:40 +0300 Subject: [PATCH 6/6] Fix tests --- tests/typecheck/managers/test_managers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/typecheck/managers/test_managers.yml b/tests/typecheck/managers/test_managers.yml index d1c470331..4abf6368e 100644 --- a/tests/typecheck/managers/test_managers.yml +++ b/tests/typecheck/managers/test_managers.yml @@ -681,7 +681,7 @@ - myapp out: | main:2: note: Revealed type is "myapp.models.MyModel.MyManager[myapp.models.MyModel]" - main:3: note: Revealed type is "Any" + main:3: note: Revealed type is "myapp.models.MyModel" files: - path: myapp/__init__.py - path: myapp/models.py