Skip to content

Run checks against Django 4.1 and Python 3.11 #1223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -83,6 +83,8 @@ jobs:
include:
- python-version: '3.7'
django-version: '2.2'
- python-version: '3.11'
django-version: '4.1'
steps:
- uses: actions/checkout@v3
- name: Setup system dependencies
Expand Down
12 changes: 9 additions & 3 deletions django-stubs/db/models/enums.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import enum
import sys
from typing import Any, List, Tuple

if sys.version_info >= (3, 11):
enum_property = enum.property
else:
enum_property = property

class ChoicesMeta(enum.EnumMeta):
names: List[str] = ...
choices: List[Tuple[Any, str]] = ...
Expand All @@ -12,7 +18,7 @@ class Choices(enum.Enum, metaclass=ChoicesMeta):
def __str__(self) -> str: ...
@property
def label(self) -> str: ...
@property
@enum_property
def value(self) -> Any: ...

# fake
Expand All @@ -23,7 +29,7 @@ class _IntegerChoicesMeta(ChoicesMeta):
values: List[int] = ...

class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta):
@property
@enum_property
def value(self) -> int: ...

# fake
Expand All @@ -34,5 +40,5 @@ class _TextChoicesMeta(ChoicesMeta):
values: List[str] = ...

class TextChoices(str, Choices, metaclass=_TextChoicesMeta):
@property
@enum_property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be supported by mypy.

Copy link
Contributor Author

@michael-k michael-k Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it the mypy-self-check job failed with

> Run mypy --cache-dir=/dev/null --no-incremental django-stubs
django-stubs/db/models/enums.pyi:16: error: Signature of "value" incompatible with supertype "Enum"
django-stubs/db/models/enums.pyi:27: error: Signature of "value" incompatible with supertype "Enum"
django-stubs/db/models/enums.pyi:38: error: Signature of "value" incompatible with supertype "Enum"
Found 3 errors in 1 file (checked 675 source files)
Error: Process completed with exit code 1.

See https://github.com/michael-k/django-stubs/actions/runs/3385444913/jobs/5623591875

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think this is necessary. The same errors also appear in #1223

Maybe add a test with reveal_type() on the value property just in case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same errors also appear in #1223

That is this PR, did you mean to link to a different one?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def value(self) -> str: ...
2 changes: 2 additions & 0 deletions django-stubs/utils/version.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ PY36: bool
PY37: bool
PY38: bool
PY39: bool
PY310: bool
PY311: bool

_VT = Tuple[int, int, int, str, int]

Expand Down
2 changes: 2 additions & 0 deletions django_stubs_ext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Typing :: Typed",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
],
project_urls={
"Release notes": "https://github.com/typeddjango/django-stubs/releases",
Expand Down
1 change: 1 addition & 0 deletions scripts/typecheck_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"2.2": "44e7cca62382f2535ed0f5d2842b433f0bd23a57",
"3.2": "0153a63a674937e4a56d9d5e4ca2d629b011fbde",
"4.0": "67d0c4644acfd7707be4a31e8976f865509b09ac",
"4.1": "7dfd29b84e5a27d61ae62cb5ed9122d5a99ee1be",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.1.3 because it's the first release that supports Python 3.11. I can point that to 4.0 if required.
django/django@7dfd29b

}
DEFAULT_DJANGO_VERSION = "3.2"

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def find_stub_files(name: str) -> List[str]:
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Typing :: Typed",
"Framework :: Django",
"Framework :: Django :: 2.2",
Expand Down