Skip to content

Commit f3a9592

Browse files
authored
1 parent 901333c commit f3a9592

File tree

11 files changed

+14
-185
lines changed

11 files changed

+14
-185
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
CIBW_ARCHS_LINUX: x86_64 i686 aarch64
2222
CIBW_ARCHS_MACOS: x86_64 universal2
2323
CIBW_ARCHS_WINDOWS: AMD64 x86 ARM64
24-
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*"
24+
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
2525

2626
steps:
2727
- uses: actions/checkout@v4

.github/workflows/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
strategy:
1919
matrix:
2020
python-version:
21-
- 3.8
2221
- 3.9
2322
- '3.10'
2423
- '3.11'

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
rev: v3.17.0
3636
hooks:
3737
- id: pyupgrade
38-
args: [--py38-plus]
38+
args: [--py39-plus]
3939
- repo: https://github.com/psf/black-pre-commit-mirror
4040
rev: 24.8.0
4141
hooks:

CHANGELOG.rst

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Changelog
33
=========
44

5+
* Drop Python 3.8 support.
6+
57
2.15.0 (2024-08-06)
68
-------------------
79

README.rst

+1-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Use **pip**:
5454
5555
python -m pip install time-machine
5656
57-
Python 3.8 to 3.13 supported.
57+
Python 3.9 to 3.13 supported.
5858
Only CPython is supported at this time because time-machine directly hooks into the C-level API.
5959

6060

@@ -210,17 +210,13 @@ Timezone mocking
210210

211211
If the ``destination`` passed to ``time_machine.travel()`` or ``Coordinates.move_to()`` has its ``tzinfo`` set to a |zoneinfo-instance2|_, the current timezone will be mocked.
212212
This will be done by calling |time-tzset|_, so it is only available on Unix.
213-
The ``zoneinfo`` module is new in Python 3.8 - on older Python versions use the |backports-zoneinfo-package|_, by the original ``zoneinfo`` author.
214213

215214
.. |zoneinfo-instance2| replace:: ``zoneinfo.ZoneInfo`` instance
216215
.. _zoneinfo-instance2: https://docs.python.org/3/library/zoneinfo.html#zoneinfo.ZoneInfo
217216

218217
.. |time-tzset| replace:: ``time.tzset()``
219218
.. _time-tzset: https://docs.python.org/3/library/time.html#time.tzset
220219

221-
.. |backports-zoneinfo-package| replace:: ``backports.zoneinfo`` package
222-
.. _backports-zoneinfo-package: https://pypi.org/project/backports.zoneinfo/
223-
224220
``time.tzset()`` changes the ``time`` module’s `timezone constants <https://docs.python.org/3/library/time.html#timezone-constants>`__ and features that rely on those, such as ``time.localtime()``.
225221
It won’t affect other concepts of “the current timezone”, such as Django’s (which can be changed with its |timezone-override|_).
226222

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ keywords = [
2222
authors = [
2323
{ name = "Adam Johnson", email = "me@adamj.eu" },
2424
]
25-
requires-python = ">=3.8"
25+
requires-python = ">=3.9"
2626
classifiers = [
2727
"Development Status :: 5 - Production/Stable",
2828
"Framework :: Pytest",
@@ -31,7 +31,6 @@ classifiers = [
3131
"Natural Language :: English",
3232
"Operating System :: OS Independent",
3333
"Programming Language :: Python :: 3 :: Only",
34-
"Programming Language :: Python :: 3.8",
3534
"Programming Language :: Python :: 3.9",
3635
"Programming Language :: Python :: 3.10",
3736
"Programming Language :: Python :: 3.11",

src/time_machine/__init__.py

+6-25
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@
77
import sys
88
import time as time_module
99
import uuid
10+
from collections.abc import Awaitable
1011
from collections.abc import Generator
12+
from collections.abc import Generator as TypingGenerator
1113
from time import gmtime as orig_gmtime
1214
from time import struct_time
1315
from types import TracebackType
1416
from typing import Any
15-
from typing import Awaitable
1617
from typing import Callable
17-
from typing import Generator as TypingGenerator
18-
from typing import Tuple
19-
from typing import Type
2018
from typing import TypeVar
2119
from typing import Union
2220
from typing import cast
2321
from typing import overload
2422
from unittest import TestCase
2523
from unittest import mock
24+
from zoneinfo import ZoneInfo
2625

2726
import _time_machine
2827
from dateutil.parser import parse as parse_datetime
@@ -43,19 +42,6 @@
4342
# Windows
4443
HAVE_TZSET = False
4544

46-
if sys.version_info >= (3, 9):
47-
from zoneinfo import ZoneInfo
48-
49-
HAVE_ZONEINFO = True
50-
else:
51-
try:
52-
from backports.zoneinfo import ZoneInfo
53-
54-
HAVE_ZONEINFO = True
55-
except ImportError: # pragma: no cover
56-
HAVE_ZONEINFO = False
57-
58-
5945
try:
6046
import pytest
6147
except ImportError: # pragma: no cover
@@ -97,10 +83,10 @@
9783

9884
_F = TypeVar("_F", bound=Callable[..., Any])
9985
_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]])
100-
TestCaseType = TypeVar("TestCaseType", bound=Type[TestCase])
86+
TestCaseType = TypeVar("TestCaseType", bound=type[TestCase])
10187

10288
# copied from typeshed:
103-
_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int]
89+
_TimeTuple = tuple[int, int, int, int, int, int, int, int, int]
10490

10591

10692
def extract_timestamp_tzname(
@@ -121,7 +107,7 @@ def extract_timestamp_tzname(
121107
elif isinstance(dest, float):
122108
timestamp = dest
123109
elif isinstance(dest, dt.datetime):
124-
if HAVE_ZONEINFO and isinstance(dest.tzinfo, ZoneInfo):
110+
if isinstance(dest.tzinfo, ZoneInfo):
125111
tzname = dest.tzinfo.key
126112
if dest.tzinfo is None:
127113
dest = dest.replace(tzinfo=dt.timezone.utc)
@@ -233,11 +219,6 @@ def start(self) -> Coordinates:
233219
_time_machine.patch_if_needed()
234220

235221
if not coordinates_stack:
236-
if sys.version_info < (3, 9):
237-
# We need to cause the functions to be loaded before we patch
238-
# them out, which is done by this internal function before:
239-
# https://github.com/python/cpython/pull/19948
240-
uuid._load_system_functions()
241222
uuid_generate_time_patcher.start()
242223
uuid_uuid_create_patcher.start()
243224

tests/requirements/compile.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*sys.argv[1:],
2020
]
2121
run = partial(subprocess.run, check=True)
22-
run([*common_args, "--python", "3.8", "--output-file", "py38.txt"])
2322
run([*common_args, "--python", "3.9", "--output-file", "py39.txt"])
2423
run([*common_args, "--python", "3.10", "--output-file", "py310.txt"])
2524
run([*common_args, "--python", "3.11", "--output-file", "py311.txt"])

tests/requirements/py38.txt

-142
This file was deleted.

tests/test_time_machine.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@
1515
from unittest import SkipTest
1616
from unittest import TestCase
1717
from unittest import mock
18+
from zoneinfo import ZoneInfo
1819

1920
import pytest
2021
from dateutil import tz
2122

2223
import time_machine
2324

24-
if sys.version_info >= (3, 9):
25-
from zoneinfo import ZoneInfo
26-
else:
27-
from backports.zoneinfo import ZoneInfo
28-
29-
3025
NANOSECONDS_PER_SECOND = time_machine.NANOSECONDS_PER_SECOND
3126
EPOCH_DATETIME = dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc)
3227
EPOCH = EPOCH_DATETIME.timestamp()

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
requires =
33
tox>=4.2
44
env_list =
5-
py{313, 312, 311, 310, 39, 38}
5+
py{313, 312, 311, 310, 39}
66

77
[testenv]
88
package = wheel

0 commit comments

Comments
 (0)