Skip to content

Run different version of mypy in ci #2671

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
mypy-version: ['1.13', '1.14', '1.15', '1.16', 'latest']
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand All @@ -38,6 +39,14 @@ jobs:
- name: Install dependencies
run: uv sync --no-dev --group tests

- name: Override mypy version
run: |
if [ "${{ matrix.mypy-version }}" == "latest" ]; then
uv pip install git+https://github.com/python/mypy.git@master
else
uv pip install mypy==${{ matrix.mypy-version }}
fi

- name: Run mypy on plugin code
run: uv run mypy --strict mypy_django_plugin
- name: Run mypy on ext code
Expand Down
2 changes: 1 addition & 1 deletion django-stubs/core/serializers/xml_serializer.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import IO, Any
from xml.sax.expatreader import ExpatParser
from xml.sax.expatreader import ExpatParser # type: ignore[import-not-found, unused-ignore]

from django.core.serializers import base

Expand Down
8 changes: 4 additions & 4 deletions django-stubs/db/models/enums.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ else:
from enum import EnumMeta as EnumType
from types import DynamicClassAttribute as enum_property

class ReprEnum(enum.Enum): ... # type: ignore[misc]
class IntEnum(int, ReprEnum): ... # type: ignore[misc]
class StrEnum(str, ReprEnum): ... # type: ignore[misc]
class ReprEnum(enum.Enum): ... # type: ignore[misc, unused-ignore]
class IntEnum(int, ReprEnum): ... # type: ignore[misc, unused-ignore]
class StrEnum(str, ReprEnum): ... # type: ignore[misc, unused-ignore]

_Self = TypeVar("_Self", bound=ChoicesType)

Expand All @@ -38,7 +38,7 @@ class ChoicesType(EnumType):
@deprecated("ChoicesMeta is deprecated in favor of ChoicesType and will be removed in Django 6.0.")
class ChoicesMeta(ChoicesType): ...

class Choices(enum.Enum, metaclass=ChoicesType): # type: ignore[misc]
class Choices(enum.Enum, metaclass=ChoicesType): # type: ignore[misc, unused-ignore]
_label_: _StrOrPromise
do_not_call_in_templates: Literal[True]

Expand Down
2 changes: 1 addition & 1 deletion mypy_django_plugin/transformers/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# TODO: [mypy 1.14+] Remove this backport of `TypeInfo.enum_members`.
def _get_enum_members(info: TypeInfo) -> list[str]:
try:
return info.enum_members
return info.enum_members # type: ignore[attr-defined, no-any-return, unused-ignore]
except AttributeError: # mypy < 1.14
pass

Expand Down
Loading