diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a012fc37a..2acfc31dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,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 @@ -56,7 +56,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: @@ -115,7 +115,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 @@ -177,7 +177,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 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..a85128af8 --- /dev/null +++ b/ext/django_stubs_ext/compat.py @@ -0,0 +1,2 @@ +# Magic constant that mypy overrides to True during type checking +MYPY: bool = False