Skip to content
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

Update enums to reflect typing spec changes #2426

Merged
merged 2 commits into from
Oct 30, 2024
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
8 changes: 4 additions & 4 deletions django-stubs/contrib/admin/options.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import enum
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from typing import Any, Generic, Literal, TypeVar, type_check_only
from typing import Any, Generic, Literal, TypeVar, cast, type_check_only

from django import forms
from django.contrib.admin.filters import FieldListFilter, ListFilter
Expand Down Expand Up @@ -45,9 +45,9 @@ VERTICAL: Literal[2]
_Direction: TypeAlias = Literal[1, 2]

class ShowFacets(enum.Enum):
NEVER: str
ALLOW: str
ALWAYS: str
NEVER = cast(str, ...)
ALLOW = cast(str, ...)
ALWAYS = cast(str, ...)

def get_content_type_for_model(obj: type[Model] | Model) -> ContentType: ...
def get_ul_class(radio_style: int) -> str: ...
Expand Down
6 changes: 3 additions & 3 deletions django-stubs/contrib/gis/gdal/srs.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from enum import IntEnum
from typing import Any, AnyStr
from typing import Any, AnyStr, cast

from django.contrib.gis.gdal.base import GDALBase
from typing_extensions import Self

class AxisOrder(IntEnum):
TRADITIONAL: int
AUTHORITY: int
TRADITIONAL = cast(int, ...)
AUTHORITY = cast(int, ...)

class SpatialReference(GDALBase):
destructor: Any
Expand Down
5 changes: 3 additions & 2 deletions django-stubs/db/models/constants.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from enum import Enum
from typing import cast

LOOKUP_SEP: str

class OnConflict(Enum):
IGNORE: str
UPDATE: str
IGNORE = cast(str, ...)
UPDATE = cast(str, ...)
6 changes: 3 additions & 3 deletions django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Sequence
from enum import Enum
from typing import Any, overload
from typing import Any, cast, overload

from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.models.base import Model
Expand All @@ -10,8 +10,8 @@ from django.utils.functional import _StrOrPromise
from typing_extensions import Self, deprecated

class Deferrable(Enum):
DEFERRED: str
IMMEDIATE: str
DEFERRED = cast(str, ...)
IMMEDIATE = cast(str, ...)

class BaseConstraint:
name: str
Expand Down
10 changes: 5 additions & 5 deletions django-stubs/template/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from enum import Enum
from logging import Logger
from re import Pattern
from typing import Any
from typing import Any, cast

from django.template.context import Context as Context # Django: imported for backwards compatibility
from django.template.engine import Engine
Expand All @@ -26,10 +26,10 @@ tag_re: Pattern[str]
logger: Logger

class TokenType(Enum):
TEXT: int
VAR: int
BLOCK: int
COMMENT: int
TEXT = cast(int, ...)
VAR = cast(int, ...)
BLOCK = cast(int, ...)
COMMENT = cast(int, ...)

class VariableDoesNotExist(Exception):
msg: str
Expand Down
Loading