Skip to content

Commit df5f478

Browse files
authored
Merge pull request #125 from ivankorobkov/github-tests-action
Add config to run unit tests with GitHub Actions and comment out modern typing syntax breaking 3.9 runtime
2 parents 5ade4e2 + 57c94e6 commit df5f478

2 files changed

Lines changed: 88 additions & 4 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
name: tests
3+
4+
"on":
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
10+
# misc:
11+
# name: "Linting configs and git"
12+
# runs-on: ubuntu-latest
13+
# steps:
14+
# - uses: actions/checkout@v4
15+
# with:
16+
# fetch-depth: 12
17+
#
18+
# - uses: docker://docker.io/tamasfe/taplo:latest
19+
# name: "Lint TOMLs"
20+
# with:
21+
# args: fmt --check --diff
22+
#
23+
# - uses: actions/setup-python@v5
24+
# - name: "Install tox"
25+
# run: |
26+
# pip install tox
27+
# - name: "Lint YAMLs"
28+
# run: |
29+
# tox -e lint-yaml
30+
# - name: "Lint git"
31+
# run: |
32+
# tox -e lint-git
33+
34+
# lint:
35+
# name: "Linting and type checking"
36+
# runs-on: ubuntu-24.04
37+
# strategy:
38+
# fail-fast: true
39+
# steps:
40+
# - uses: actions/checkout@v4
41+
# - uses: actions/setup-python@v5
42+
# with:
43+
# python-version: "3.13"
44+
# - name: "Install tox"
45+
# run: |
46+
# pip install tox
47+
# - name: "Lint formatting"
48+
# run: |
49+
# tox -e lint-py
50+
# - name: "Type checking"
51+
# run: |
52+
# tox -e lint-mypy
53+
54+
tests:
55+
name: "Run unit tests"
56+
runs-on: ubuntu-24.04
57+
strategy:
58+
fail-fast: true
59+
matrix:
60+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: actions/setup-python@v5
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
- name: "Installing tox"
67+
run: pip install tox
68+
- name: "Executing unit tests"
69+
run: |
70+
tox run -e ${{ matrix.python-version }}

src/inject/__init__.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def my_config(binder):
7373
inject.configure(my_config)
7474
7575
"""
76+
from __future__ import annotations
77+
7678
import contextlib
7779

7880
from inject._version import __version__
@@ -84,7 +86,7 @@ def my_config(binder):
8486
from functools import wraps
8587
from typing import (Any, Awaitable, Callable, Dict, Generic, Hashable,
8688
Optional, Set, Type, TypeVar, Union, cast, get_type_hints,
87-
overload, no_type_check, Self)
89+
overload, no_type_check)
8890

8991
_HAS_PEP604_SUPPORT = sys.version_info[:3] >= (3, 10, 0) # PEP 604
9092
if _HAS_PEP604_SUPPORT:
@@ -214,8 +216,12 @@ def __init__(
214216
else:
215217
self._bindings = {}
216218

219+
# NOTE(pyctrl): only since 3.12
220+
# @overload
221+
# def get_instance(self, cls: Type[T]) -> T: ...
222+
217223
@overload
218-
def get_instance(self, cls: Type[T]) -> T: ...
224+
def get_instance(self, cls: Binding) -> T: ...
219225

220226
@overload
221227
def get_instance(self, cls: Hashable) -> Injectable: ...
@@ -521,11 +527,19 @@ def sign_up(name, email, cache, db):
521527
return _ParametersInjection(**args_to_classes)
522528

523529

530+
# NOTE(pyctrl): only since 3.12
531+
# @overload
532+
# def autoparams[T](fn: Callable[..., T]) -> Callable[..., T]: ...
533+
524534
@overload
525-
def autoparams[T](fn: Callable[..., T]) -> Callable[..., T]: ...
535+
def autoparams(fn: Callable) -> Callable: ...
536+
537+
# NOTE(pyctrl): only since 3.12
538+
# @overload
539+
# def autoparams[C: Callable](*selected: str) -> Callable[[C], C]: ...
526540

527541
@overload
528-
def autoparams[C: Callable](*selected: str) -> Callable[[C], C]: ...
542+
def autoparams(*selected: str) -> Callable: ...
529543

530544
@no_type_check
531545
def autoparams(*selected: str):

0 commit comments

Comments
 (0)