Skip to content

Commit

Permalink
remove django-stubs #60
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Mar 11, 2024
1 parent 25b46ab commit cc6ac00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 3 additions & 8 deletions django_enum/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

_Choice = Tuple[Any, Any]
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
_FieldChoices = Iterable[_Choice | _ChoiceNamedGroup]
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]


class _ChoicesCallable(Protocol):
Expand Down Expand Up @@ -286,20 +286,15 @@ def validate(self, value):
)


# seems to be a type hinting bug when django-stubs and mypy are used together where
# these classes are confused about what type the choices property is - hence the ignore
# comments - these comments are unnecessary when django-stubs is not installed


class EnumChoiceField(ChoiceFieldMixin, TypedChoiceField): # type: ignore
class EnumChoiceField(ChoiceFieldMixin, TypedChoiceField):
"""
The default ``ChoiceField`` will only accept the base enumeration values.
Use this field on forms to accept any value mappable to an enumeration
including any labels or symmetric properties.
"""


class EnumFlagField(ChoiceFieldMixin, TypedMultipleChoiceField): # type: ignore
class EnumFlagField(ChoiceFieldMixin, TypedMultipleChoiceField):
"""
The default ``TypedMultipleChoiceField`` will only accept the base
enumeration values. Use this field on forms to accept any value mappable
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ numpy = [
]
pylint = "^3.1.0"
black = "^24.2.0"
django-stubs = {extras = ["compatible-mypy"], version = "^4.2.7"}
# django-stubs = {extras = ["compatible-mypy"], version = "^4.2.7"}

[tool.poetry.group.psycopg2]
optional = true
Expand Down Expand Up @@ -138,7 +138,7 @@ warn_no_return = true
exclude = [
"tests",
]
plugins = ["mypy_django_plugin.main"]
# plugins = ["mypy_django_plugin.main"]


# todo doc8 configuration here is not being picked up and doesnt seem to be working
Expand Down Expand Up @@ -176,8 +176,8 @@ disable = [
'R0801'
]

[tool.django-stubs]
django_settings_module = "django_enum.tests.settings"
# [tool.django-stubs]
# django_settings_module = "django_enum.tests.settings"

[tool.pytest.ini_options]
# py.test options:
Expand Down

0 comments on commit cc6ac00

Please sign in to comment.