Skip to content

Commit e4d6204

Browse files
committed
5.0: Remove pytz support
1 parent d58ea50 commit e4d6204

File tree

6 files changed

+15
-34
lines changed

6 files changed

+15
-34
lines changed

django-stubs/conf/global_settings.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ TIME_ZONE: str
4040

4141
# If you set this to True, Django will use timezone-aware datetimes.
4242
USE_TZ: bool
43-
USE_DEPRECATED_PYTZ: bool
4443

4544
# Language code for this installation. All choices can be found here:
4645
# http://www.i18nguy.com/unicode/language-identifiers.html

django-stubs/db/backends/base/base.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ _ExecuteWrapper: TypeAlias = Callable[
2424
[Callable[[str, Any, bool, dict[str, Any]], Any], str, Any, bool, dict[str, Any]], Any
2525
]
2626

27-
def timezone_constructor(tzname: str) -> tzinfo: ...
28-
2927
class BaseDatabaseWrapper:
3028
data_types: dict[str, str]
3129
data_types_suffix: dict[str, str]

django-stubs/templatetags/tz.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ from typing import Any
33

44
from django.template import Node
55
from django.template.base import FilterExpression, NodeList, Parser, Token
6-
from django.utils.timezone import _TzInfoT
76

87
register: Any
98

109
class datetimeobject(datetime): ...
1110

1211
def localtime(value: datetime | str | None) -> Any: ...
1312
def utc(value: datetime | str | None) -> Any: ...
14-
def do_timezone(value: datetime | str | None, arg: _TzInfoT | str | None) -> Any: ...
13+
def do_timezone(value: datetime | str | None, arg: datetime.tzinfo | str | None) -> Any: ...
1514

1615
class LocalTimeNode(Node):
1716
nodelist: NodeList

django-stubs/utils/dateformat.pyi

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from datetime import date
1+
from datetime import date, tzinfo
22
from datetime import datetime as builtin_datetime
33
from datetime import time as builtin_time
44
from re import Pattern
55
from typing import Any, Literal
66

7-
from django.utils.timezone import _TzInfoT
8-
97
re_formatchars: Pattern[str]
108
re_escaped: Pattern[str]
119

@@ -14,7 +12,7 @@ class Formatter:
1412

1513
class TimeFormat(Formatter):
1614
data: builtin_datetime | builtin_time
17-
timezone: _TzInfoT | None
15+
timezone: tzinfo | None
1816
def __init__(self, obj: builtin_datetime | builtin_time) -> None: ...
1917
def a(self) -> str: ...
2018
def A(self) -> str: ...
@@ -34,7 +32,7 @@ class TimeFormat(Formatter):
3432

3533
class DateFormat(TimeFormat):
3634
data: builtin_datetime | date | builtin_time # type: ignore[assignment]
37-
timezone: _TzInfoT | None
35+
timezone: tzinfo | None
3836
year_days: Any
3937
def __init__(self, obj: builtin_datetime | builtin_time | date) -> None: ...
4038
def b(self) -> str: ...

django-stubs/utils/timezone.pyi

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,22 @@ from datetime import date, datetime, time, timedelta, timezone, tzinfo
33
from types import TracebackType
44
from typing import Any, Literal, overload
55

6-
import pytz
7-
from pytz import BaseTzInfo
8-
from typing_extensions import TypeAlias, TypeGuard
9-
10-
_PytzTzInfoT: TypeAlias = pytz.tzinfo.BaseTzInfo | pytz._FixedOffset
11-
12-
_TzInfoT: TypeAlias = _PytzTzInfoT | tzinfo
6+
import zoneinfo
137

148
utc: Any
159

1610
def get_fixed_timezone(offset: timedelta | int) -> timezone: ...
17-
def get_default_timezone() -> BaseTzInfo: ...
11+
def get_default_timezone() -> zoneinfo.ZoneInfo: ...
1812
def get_default_timezone_name() -> str: ...
19-
20-
# Strictly speaking, it is possible to activate() a non-pytz timezone,
21-
# in which case BaseTzInfo is incorrect. However, this is unlikely,
22-
# so we use it anyway, to keep things ergonomic for most users.
23-
def get_current_timezone() -> BaseTzInfo: ...
13+
def get_current_timezone() -> zoneinfo.ZoneInfo: ...
2414
def get_current_timezone_name() -> str: ...
25-
def activate(timezone: _TzInfoT | str) -> None: ...
15+
def activate(timezone: tzinfo | str) -> None: ...
2616
def deactivate() -> None: ...
2717

2818
class override(ContextDecorator):
29-
timezone: str | _TzInfoT | None
30-
old_timezone: _TzInfoT | None
31-
def __init__(self, timezone: str | _TzInfoT | None) -> None: ...
19+
timezone: str | tzinfo | None
20+
old_timezone: tzinfo | None
21+
def __init__(self, timezone: str | tzinfo | None) -> None: ...
3222
def __enter__(self) -> None: ...
3323
def __exit__(
3424
self,
@@ -37,8 +27,8 @@ class override(ContextDecorator):
3727
exc_tb: TracebackType | None,
3828
) -> None: ...
3929

40-
def localtime(value: datetime | None = ..., timezone: _TzInfoT | None = ...) -> datetime: ...
41-
def localdate(value: datetime | None = ..., timezone: _TzInfoT | None = ...) -> date: ...
30+
def localtime(value: datetime | None = ..., timezone: tzinfo | None = ...) -> datetime: ...
31+
def localdate(value: datetime | None = ..., timezone: tzinfo | None = ...) -> date: ...
4232
def now() -> datetime: ...
4333
@overload
4434
def is_aware(value: time) -> Literal[False]: ...
@@ -48,6 +38,5 @@ def is_aware(value: datetime) -> bool: ...
4838
def is_naive(value: time) -> Literal[True]: ...
4939
@overload
5040
def is_naive(value: datetime) -> bool: ...
51-
def make_aware(value: datetime, timezone: _TzInfoT | None = ..., is_dst: bool | None = ...) -> datetime: ...
52-
def make_naive(value: datetime, timezone: _TzInfoT | None = ...) -> datetime: ...
53-
def _is_pytz_zone(tz: _TzInfoT) -> TypeGuard[_PytzTzInfoT]: ...
41+
def make_aware(value: datetime, timezone: tzinfo | None = ..., is_dst: bool | None = ...) -> datetime: ...
42+
def make_naive(value: datetime, timezone: tzinfo | None = ...) -> datetime: ...

scripts/stubtest/allowlist_todo_django50.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
django.conf.FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG
66
django.conf.global_settings.CSRF_COOKIE_MASKED
77
django.conf.global_settings.FORMS_URLFIELD_ASSUME_HTTPS
8-
django.conf.global_settings.USE_DEPRECATED_PYTZ
98
django.conf.global_settings.USE_L10N
109
django.contrib.admin.AdminSite.get_model_admin
1110
django.contrib.admin.AllValuesFieldListFilter.get_facet_counts
@@ -109,7 +108,6 @@ django.core.handlers.asgi.get_script_prefix
109108
django.core.management.commands.inspectdb.Command.normalize_table_name
110109
django.core.management.commands.optimizemigration
111110
django.core.serializers.base.PickleSerializer
112-
django.db.backends.base.base.timezone_constructor
113111
django.db.backends.base.features.BaseDatabaseFeatures.delete_can_self_reference_subquery
114112
django.db.backends.base.features.BaseDatabaseFeatures.insert_test_table_with_defaults
115113
django.db.backends.base.features.BaseDatabaseFeatures.supports_default_keyword_in_bulk_insert

0 commit comments

Comments
 (0)