From 0bf4e9837871ab57cc69c040bda8c7afcdc7a821 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 9 Oct 2025 12:09:51 +0300 Subject: [PATCH 1/4] Add test with 3.14 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 765d3d965..516c9b624 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11', '3.12', '3.13'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] fail-fast: false steps: - uses: actions/checkout@v5 From 7c8d87d9c6a3f23abc0f51df4cae318a4034a0f3 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 9 Oct 2025 12:19:49 +0300 Subject: [PATCH 2/4] Update test.yml --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 516c9b624..d5636ae91 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11', '3.12', '3.13'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] shard: [0, 1, 2, 3] fail-fast: false steps: @@ -113,7 +113,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.12', '3.13'] + python-version: ['3.12', '3.13', '3.14'] fail-fast: false steps: - uses: actions/checkout@v5 @@ -175,7 +175,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10', '3.11', '3.12', '3.13'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] django-version: ['5.0', '5.1', '5.2'] steps: - uses: actions/checkout@v5 From 74bdf92c3b882cc7a6d5f2fd231e17773e964f98 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Mon, 17 Nov 2025 22:26:13 +0200 Subject: [PATCH 3/4] Ignore {Integer,Text}Choices.__init__ with mypy --- django-stubs/db/models/enums.pyi | 22 ++++++++++++++-------- ext/django_stubs_ext/compat.py | 4 ++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 ext/django_stubs_ext/compat.py diff --git a/django-stubs/db/models/enums.pyi b/django-stubs/db/models/enums.pyi index e6ce888a7..614ab6413 100644 --- a/django-stubs/db/models/enums.pyi +++ b/django-stubs/db/models/enums.pyi @@ -6,6 +6,8 @@ from _typeshed import ConvertibleToInt from django.utils.functional import _StrOrPromise from typing_extensions import deprecated +from django_stubs_ext.compat import MYPY + if sys.version_info >= (3, 11): from enum import EnumType, IntEnum, StrEnum from enum import property as enum_property @@ -59,10 +61,12 @@ class _IntegerChoicesType(ChoicesType): # 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=_IntegerChoicesType): # type: ignore[misc] - @overload - def __init__(self, x: ConvertibleToInt) -> None: ... - @overload - def __init__(self, x: ConvertibleToInt, label: _StrOrPromise) -> None: ... + if not MYPY: # noqa: PYI002 + @overload + def __init__(self, x: ConvertibleToInt) -> None: ... + @overload + def __init__(self, x: ConvertibleToInt, label: _StrOrPromise) -> None: ... + @enum_property def value(self) -> int: ... @@ -75,10 +79,12 @@ class _TextChoicesType(ChoicesType): def values(self) -> list[str]: ... class TextChoices(Choices, StrEnum, metaclass=_TextChoicesType): # type: ignore[misc] - @overload - def __init__(self, object: str) -> None: ... - @overload - def __init__(self, object: str, label: _StrOrPromise) -> None: ... + if not MYPY: # noqa: PYI002 + @overload + def __init__(self, object: str) -> None: ... + @overload + def __init__(self, object: str, label: _StrOrPromise) -> None: ... + @enum_property def value(self) -> str: ... diff --git a/ext/django_stubs_ext/compat.py b/ext/django_stubs_ext/compat.py new file mode 100644 index 000000000..3cbef4510 --- /dev/null +++ b/ext/django_stubs_ext/compat.py @@ -0,0 +1,4 @@ +from typing import Literal + +# Magic constant that mypy overrides to True during type checking +MYPY: Literal[False] From ef25b0100126cbf658d8d4dda1168e83ccb6f750 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Mon, 17 Nov 2025 22:34:47 +0200 Subject: [PATCH 4/4] Fix MYPY constant --- ext/django_stubs_ext/compat.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/django_stubs_ext/compat.py b/ext/django_stubs_ext/compat.py index 3cbef4510..a85128af8 100644 --- a/ext/django_stubs_ext/compat.py +++ b/ext/django_stubs_ext/compat.py @@ -1,4 +1,2 @@ -from typing import Literal - # Magic constant that mypy overrides to True during type checking -MYPY: Literal[False] +MYPY: bool = False