Skip to content

Commit 890d305

Browse files
committed
Drop support for Python 3.8 and 3.9
They are end-of-life.
1 parent 6de2990 commit 890d305

9 files changed

Lines changed: 16 additions & 46 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ jobs:
1414
os: [ubuntu-latest]
1515
python-version:
1616
[
17-
3.8,
18-
3.9,
1917
"3.10",
2018
"3.11",
2119
"3.12",
2220
"3.13",
2321
"3.14",
24-
"pypy3.8",
25-
"pypy3.9",
22+
"3.15",
2623
"pypy3.10",
2724
"pypy3.11",
2825
]

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Injector Change Log
22
===================
33

4+
0.25.0
5+
------
6+
7+
- Dropped support for Python 3.8 and 3.9. Python 3.10+ is now required.
8+
49
0.24.0
510
------
611

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The core values of Injector are:
7272
* Documentation: https://injector.readthedocs.org
7373
* Change log: https://injector.readthedocs.io/en/latest/changelog.html
7474

75-
Injector works with CPython 3.8+ and PyPy 3 implementing Python 3.8+.
75+
Injector works with CPython 3.10+ and PyPy 3 implementing Python 3.10+.
7676

7777
A Quick Example
7878
---------------

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ PyPI (installable, stable distributions): https://pypi.org/project/injector. You
2121

2222
pip install injector
2323

24-
Injector works with CPython 3.6+ and PyPy 3 implementing Python 3.6+.
24+
Injector works with CPython 3.10+ and PyPy 3 implementing Python 3.10+.
2525

2626
Introduction
2727
------------

injector/__init__.py

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,7 @@
4545
overload,
4646
)
4747

48-
try:
49-
from typing import NoReturn
50-
except ImportError:
51-
from typing_extensions import NoReturn
52-
53-
# This is a messy, type-wise, because we not only have two potentially conflicting imports here
54-
# The easiest way to make mypy happy here is to tell it the versions from typing_extensions are
55-
# canonical. Since this typing_extensions import is only for mypy it'll work even without
56-
# typing_extensions actually installed so all's good.
57-
if TYPE_CHECKING:
58-
from typing_extensions import Annotated, _AnnotatedAlias, get_type_hints
59-
else:
60-
# Ignoring errors here as typing_extensions stub doesn't know about those things yet
61-
try:
62-
from typing import Annotated, _AnnotatedAlias, get_type_hints
63-
except ImportError:
64-
from typing_extensions import Annotated, _AnnotatedAlias, get_type_hints
48+
from typing import Annotated, NoReturn, _AnnotatedAlias, get_type_hints
6549

6650

6751
__author__ = 'Alec Thomas <alec@swapoff.org>'
@@ -108,7 +92,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
10892
InjectT = TypeVar('InjectT')
10993
Inject = Annotated[InjectT, _inject_marker]
11094
"""An experimental way to declare injectable dependencies utilizing a `PEP 593`_ implementation
111-
in Python 3.9 and backported to Python 3.7+ in `typing_extensions`.
95+
in Python 3.9.
11296
11397
Those two declarations are equivalent::
11498
@@ -136,19 +120,18 @@ def fun(t: Inject[SomeType], s: SomeOtherType) -> None:
136120
A way to inspect how various injection declarations interact with each other.
137121
138122
.. versionadded:: 0.18.0
139-
.. note:: Requires Python 3.7+.
123+
.. note:: Requires Python 3.9+.
140124
.. note::
141125
142126
If you're using mypy you need the version 0.750 or newer to fully type-check code using this
143127
construct.
144128
145129
.. _PEP 593: https://www.python.org/dev/peps/pep-0593/
146-
.. _typing_extensions: https://pypi.org/project/typing-extensions/
147130
"""
148131

149132
NoInject = Annotated[InjectT, _noinject_marker]
150133
"""An experimental way to declare noninjectable dependencies utilizing a `PEP 593`_ implementation
151-
in Python 3.9 and backported to Python 3.7+ in `typing_extensions`.
134+
in Python 3.9.
152135
153136
Since :func:`inject` declares all function's parameters to be injectable there needs to be a way
154137
to opt out of it. This has been provided by :func:`noninjectable` but `noninjectable` suffers from
@@ -175,14 +158,13 @@ def fun(a: TypeA, b: NoInject[TypeB]) -> None:
175158
A way to inspect how various injection declarations interact with each other.
176159
177160
.. versionadded:: 0.18.0
178-
.. note:: Requires Python 3.7+.
161+
.. note:: Requires Python 3.9+.
179162
.. note::
180163
181164
If you're using mypy you need the version 0.750 or newer to fully type-check code using this
182165
construct.
183166
184167
.. _PEP 593: https://www.python.org/dev/peps/pep-0593/
185-
.. _typing_extensions: https://pypi.org/project/typing-extensions/
186168
"""
187169

188170

@@ -791,13 +773,7 @@ def _ensure_iterable(item_or_list: Union[T, List[T]]) -> List[T]:
791773

792774

793775
def _punch_through_alias(type_: Any) -> type:
794-
if (
795-
sys.version_info < (3, 10)
796-
and getattr(type_, '__qualname__', '') == 'NewType.<locals>.new_type'
797-
or sys.version_info >= (3, 10)
798-
and type(type_).__module__ == 'typing'
799-
and type(type_).__name__ == 'NewType'
800-
):
776+
if type(type_).__module__ == 'typing' and type(type_).__name__ == 'NewType':
801777
return type_.__supertype__
802778
elif isinstance(type_, _AnnotatedAlias) and getattr(type_, '__metadata__', None) is not None:
803779
return type_.__origin__

injector_test.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@
1111
"""Functional tests for the "Injector" dependency injection framework."""
1212

1313
import abc
14-
import sys
1514
import threading
1615
import traceback
1716
import warnings
1817
from contextlib import contextmanager
1918
from dataclasses import dataclass
2019
from typing import Any, Literal, NewType, Optional, Union
2120

22-
if sys.version_info >= (3, 9):
23-
from typing import Annotated
24-
else:
25-
from typing_extensions import Annotated
21+
from typing import Annotated
2622

2723
from typing import Dict, List, NewType
2824

@@ -2031,7 +2027,6 @@ def function(a: Inject[Inject[int]]) -> None:
20312027

20322028

20332029
# Tests https://github.com/alecthomas/injector/issues/202
2034-
@pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10+")
20352030
def test_get_bindings_for_pep_604():
20362031
@inject
20372032
def function1(a: int | None) -> None:
@@ -2255,7 +2250,6 @@ def provide_second(self) -> Annotated[str, 'second']:
22552250

22562251

22572252
# Test for https://github.com/alecthomas/injector/issues/303
2258-
@pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10+")
22592253
def test_can_inject_dataclass_with_literal_value():
22602254
@dataclass(slots=True)
22612255
class ServiceConfig:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[tool.black]
22
line-length = 110
3-
target_version = ['py36', 'py37']
3+
target_version = ['py310', 'py311', 'py312']
44
skip_string_normalization = true

requirements-dev.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ pytest-cov>=2.5.1
1111
mypy;implementation_name=="cpython"
1212
black;implementation_name=="cpython"
1313
check-manifest
14-
typing_extensions>=3.7.4;python_version<"3.9"

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
typing_extensions>=3.7.4;python_version<"3.9"

0 commit comments

Comments
 (0)