Skip to content
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
70 changes: 70 additions & 0 deletions django-stubs/contrib/gis/geoip2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from ipaddress import IPv4Address, IPv6Address
from typing import Final, TypeAlias, TypedDict

from _typeshed import StrPath
from django.contrib.gis.geos import Point
from django.utils.functional import cached_property

HAS_GEOIP2: bool
SUPPORTED_DATABASE_TYPES: set[str]

_CoordType: TypeAlias = tuple[float, float] | tuple[None, None]
_QueryType: TypeAlias = str | IPv4Address | IPv6Address

class _CityResponse(TypedDict):
accuracy_radius: int | None
city: str
continent_code: str
continent_name: str
country_code: str
country_name: str
is_in_european_union: bool
latitude: float
longitude: float
metro_code: int | None
postal_code: str | None
region_code: str | None
region_name: str | None
time_zone: str | None
# Kept for backward compatibility.
dma_code: int | None
region: str | None

class _CountryResponse(TypedDict):
continent_code: str
continent_name: str
country_code: str
country_name: str
is_in_european_union: bool

class GeoIP2Exception(Exception): ...

class GeoIP2:
MODE_AUTO: Final = 0
MODE_MMAP_EXT: Final = 1
MODE_MMAP: Final = 2
MODE_FILE: Final = 4
MODE_MEMORY: Final = 8
cache_options: Final[frozenset[int]]

def __init__(
self,
path: StrPath | None = None,
cache: int = 0,
country: str | None = None,
city: str | None = None,
) -> None: ...
def __del__(self) -> None: ...
@cached_property
def is_city(self) -> bool: ...
@cached_property
def is_country(self) -> bool: ...
def city(self, query: _QueryType) -> _CityResponse: ...
def country_code(self, query: _QueryType) -> str: ...
def country_name(self, query: _QueryType) -> str: ...
def country(self, query: _QueryType) -> _CountryResponse: ...
def lon_lat(self, query: _QueryType) -> _CoordType: ...
def lat_lon(self, query: _QueryType) -> _CoordType: ...
def geos(self, query: _QueryType) -> Point: ...

__all__ = ["HAS_GEOIP2"]
4 changes: 0 additions & 4 deletions django-stubs/contrib/gis/geoip2/__init__.pyi

This file was deleted.

33 changes: 0 additions & 33 deletions django-stubs/contrib/gis/geoip2/base.pyi

This file was deleted.

4 changes: 0 additions & 4 deletions django-stubs/contrib/gis/geoip2/resources.pyi

This file was deleted.

40 changes: 20 additions & 20 deletions django-stubs/forms/fields.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from collections.abc import Callable, Collection, Iterator, Sequence
from collections.abc import Callable, Collection, Iterable, Iterator, Sequence
from decimal import Decimal
from re import Pattern
from typing import Any, ClassVar, Protocol, TypeAlias, type_check_only
Expand Down Expand Up @@ -52,7 +52,7 @@ class Field:
help_text: _StrOrPromise = "",
error_messages: _ErrorMessagesMapping | None = None,
show_hidden_initial: bool = False,
validators: Sequence[_ValidatorCallable] = (),
validators: Iterable[_ValidatorCallable] = (),
localize: bool = False,
disabled: bool = False,
label_suffix: str | None = None,
Expand Down Expand Up @@ -89,7 +89,7 @@ class CharField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -118,7 +118,7 @@ class IntegerField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -142,7 +142,7 @@ class FloatField(IntegerField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -172,7 +172,7 @@ class DecimalField(IntegerField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -197,7 +197,7 @@ class BaseTemporalField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -255,7 +255,7 @@ class RegexField(CharField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -277,7 +277,7 @@ class EmailField(CharField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -299,7 +299,7 @@ class FileField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -335,7 +335,7 @@ class URLField(CharField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -377,7 +377,7 @@ class ChoiceField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -412,7 +412,7 @@ class TypedChoiceField(ChoiceField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -446,7 +446,7 @@ class TypedMultipleChoiceField(MultipleChoiceField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -469,7 +469,7 @@ class ComboField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -492,7 +492,7 @@ class MultiValueField(Field):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down Expand Up @@ -530,7 +530,7 @@ class FilePathField(ChoiceField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -553,7 +553,7 @@ class SplitDateTimeField(MultiValueField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -575,7 +575,7 @@ class GenericIPAddressField(CharField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand All @@ -600,7 +600,7 @@ class SlugField(CharField):
help_text: _StrOrPromise = ...,
error_messages: _ErrorMessagesMapping | None = ...,
show_hidden_initial: bool = ...,
validators: Sequence[_ValidatorCallable] = ...,
validators: Iterable[_ValidatorCallable] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: str | None = ...,
Expand Down
4 changes: 3 additions & 1 deletion s/sync
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ set -e

DJANGO_STUBS_TARGET_TAG="6.0.5"
git fetch https://github.com/typeddjango/django-stubs.git $DJANGO_STUBS_TARGET_TAG
git checkout $DJANGO_STUBS_TARGET_TAG -- django-stubs/tasks/ django-stubs/core/cache
git checkout $DJANGO_STUBS_TARGET_TAG -- \
django-stubs/tasks/ \
django-stubs/core/cache/

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SYNC_FILES="$SCRIPT_DIR/sync-files.txt"
Expand Down
1 change: 1 addition & 0 deletions s/sync-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ django-stubs/utils/csp.pyi
django-stubs/contrib/admin/tests.pyi
#django-stubs/utils/html.pyi
django-stubs/core/signing.pyi
django-stubs/contrib/gis/geoip2.pyi
Loading
Loading