Skip to content

Commit c3cde79

Browse files
Revert "Add mypy to the CI"
This reverts commit c3a31bb. Mypy itself crashes on the tip of the branch, and it provides little value in its current state. ``` $ mypy tests --no-check-untyped-defs /home/runner/work/django-phonenumber-field/django-phonenumber-field/.tox/mypy/lib/python3.13/site-packages/django-stubs/contrib/auth/forms.pyi:82: error: INTERNAL ERROR -- Please try using mypy master on GitHub: https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues version: 1.17.1 ``` #567 was offered to improve the type checking, but that PR introduces convoluted workarounds to runtime code, for type checking usage. We can reconsider when Django officially supports typing or when the typing ecosystem can be used to better document and verify the code, without requiring complex workarounds. https://github.com/stefanfoulis/django-phonenumber-field/pull/567/files#diff-82109bfd2869a9307c952d21292dc118e522d7fb07ca87d1e607ff9b192c666fR51-R60
1 parent 632b84b commit c3cde79

File tree

5 files changed

+1
-38
lines changed

5 files changed

+1
-38
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
matrix:
1515
tox-environment:
1616
- doctest
17-
- mypy
1817
- ruff
1918
env:
2019
TOXENV: ${{ matrix.tox-environment }}

phonenumber_field/phonenumber.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
from __future__ import annotations
22

33
from functools import total_ordering
4-
from typing import TYPE_CHECKING
54

65
import phonenumbers
76
from django.conf import settings
87
from django.core import validators
98

10-
if TYPE_CHECKING:
11-
# Use ‘from typing import Self’ from Python 3.11 onwards.
12-
from typing_extensions import Self
13-
149

1510
@total_ordering
1611
class PhoneNumber(phonenumbers.PhoneNumber):
@@ -28,7 +23,7 @@ class PhoneNumber(phonenumbers.PhoneNumber):
2823
}
2924

3025
@classmethod
31-
def from_string(cls, phone_number, region=None) -> Self:
26+
def from_string(cls, phone_number, region=None):
3227
"""
3328
:arg str phone_number: parse this :class:`str` as a phone number.
3429
:keyword str region: 2-letter country code as defined in ISO 3166-1.

pyproject.toml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,5 @@ requires = [
6767
]
6868
build-backend = "setuptools.build_meta"
6969

70-
[tool.mypy]
71-
python_version = "3.9"
72-
check_untyped_defs = true
73-
show_error_context = true
74-
pretty = true
75-
plugins = ["mypy_django_plugin.main", "mypy_drf_plugin.main"]
76-
warn_no_return = true
77-
warn_redundant_casts = true
78-
warn_return_any = true
79-
warn_unreachable = true
80-
warn_unused_configs = true
81-
warn_unused_ignores = true
82-
83-
[tool.django-stubs]
84-
django_settings_module = "tests.settings"
85-
8670
[tool.setuptools_scm]
8771
write_to = "phonenumber_field/version.py"

tests/test_formfields.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class TestForm(forms.Form):
148148
class SplitPhoneNumberFormFieldTest(SimpleTestCase):
149149
def example_number(self, region_code: str) -> PhoneNumber:
150150
number = phonenumbers.example_number(region_code)
151-
assert number is not None
152151
e164 = phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.E164)
153152
return PhoneNumber.from_string(e164, region=region_code)
154153

tox.ini

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ envlist =
66
dj51
77
dj52
88
djmain
9-
mypy
109
isolated_build = true
1110
minversion = 1.9
1211

@@ -54,16 +53,3 @@ changedir = docs/
5453
allowlist_externals=make
5554
commands =
5655
make doctest
57-
58-
[testenv:mypy]
59-
commands =
60-
mypy phonenumber_field
61-
mypy tests --no-check-untyped-defs
62-
deps =
63-
typing_extensions
64-
Django
65-
phonenumbers
66-
djangorestframework
67-
django-stubs[compatible-mypy]
68-
djangorestframework-stubs
69-
types-babel

0 commit comments

Comments
 (0)