Skip to content

Commit 05bcc15

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

9 files changed

Lines changed: 15 additions & 47 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ 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",
2622
"pypy3.10",
2723
"pypy3.11",
2824
]

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 & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from abc import ABCMeta, abstractmethod
2525
from dataclasses import dataclass
2626
from typing import (
27-
TYPE_CHECKING,
2827
Any,
2928
Callable,
3029
Collection,
@@ -45,23 +44,7 @@
4544
overload,
4645
)
4746

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
47+
from typing import Annotated, NoReturn, _AnnotatedAlias, get_type_hints # type: ignore[attr-defined]
6548

6649

6750
__author__ = 'Alec Thomas <alec@swapoff.org>'
@@ -108,7 +91,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
10891
InjectT = TypeVar('InjectT')
10992
Inject = Annotated[InjectT, _inject_marker]
11093
"""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`.
94+
in Python 3.9.
11295
11396
Those two declarations are equivalent::
11497
@@ -136,19 +119,18 @@ def fun(t: Inject[SomeType], s: SomeOtherType) -> None:
136119
A way to inspect how various injection declarations interact with each other.
137120
138121
.. versionadded:: 0.18.0
139-
.. note:: Requires Python 3.7+.
122+
.. note:: Requires Python 3.9+.
140123
.. note::
141124
142125
If you're using mypy you need the version 0.750 or newer to fully type-check code using this
143126
construct.
144127
145128
.. _PEP 593: https://www.python.org/dev/peps/pep-0593/
146-
.. _typing_extensions: https://pypi.org/project/typing-extensions/
147129
"""
148130

149131
NoInject = Annotated[InjectT, _noinject_marker]
150132
"""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`.
133+
in Python 3.9.
152134
153135
Since :func:`inject` declares all function's parameters to be injectable there needs to be a way
154136
to opt out of it. This has been provided by :func:`noninjectable` but `noninjectable` suffers from
@@ -175,14 +157,13 @@ def fun(a: TypeA, b: NoInject[TypeB]) -> None:
175157
A way to inspect how various injection declarations interact with each other.
176158
177159
.. versionadded:: 0.18.0
178-
.. note:: Requires Python 3.7+.
160+
.. note:: Requires Python 3.9+.
179161
.. note::
180162
181163
If you're using mypy you need the version 0.750 or newer to fully type-check code using this
182164
construct.
183165
184166
.. _PEP 593: https://www.python.org/dev/peps/pep-0593/
185-
.. _typing_extensions: https://pypi.org/project/typing-extensions/
186167
"""
187168

188169

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

792773

793774
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-
):
775+
if type(type_).__module__ == 'typing' and type(type_).__name__ == 'NewType':
801776
return type_.__supertype__
802777
elif isinstance(type_, _AnnotatedAlias) and getattr(type_, '__metadata__', None) is not None:
803778
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']
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)