Skip to content

Commit 93fd552

Browse files
authored
chore(*): Remove Python 3.7 and Python 3.8 support and add Python 3.11, Python 3.12 and Python 3.13 support (#18)
1 parent 42dc93e commit 93fd552

23 files changed

+209
-155
lines changed

.github/workflows/cd.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
env:
1616
VERSION: ${{ github.event.inputs.release_version }}
1717
steps:
18-
- uses: actions/checkout@v3
19-
- uses: actions/setup-python@v4
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
2020
with:
21-
python-version: '3.10'
21+
python-version: '3.13.0-rc.2'
2222
- name: version
2323
run: sed -i "s/__version__ = '.*'/__version__ = '$VERSION'/g" aiodi/__init__.py
2424
- name: deps

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ ubuntu-latest ]
17-
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
17+
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.2' ]
1818
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions/setup-python@v4
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323
- name: deps

Containerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM docker.io/continuumio/miniconda3:latest AS miniconda3
2+
3+
WORKDIR /app
4+
5+
RUN conda install -y --download-only "python=3.12" && \
6+
conda install -y --download-only "python=3.11" && \
7+
conda install -y --download-only "python=3.10" && \
8+
conda install -y --download-only "python=3.9"
9+
10+
COPY . ./
11+
12+
ENTRYPOINT ["python3"]
13+
CMD ["run-script"]
14+
15+
FROM miniconda3 AS py312
16+
17+
RUN conda install -y "python=3.12"
18+
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install
19+
20+
FROM miniconda3 AS py311
21+
22+
RUN conda install -y "python=3.11"
23+
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install
24+
25+
FROM miniconda3 AS py310
26+
27+
RUN conda install -y "python=3.10"
28+
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install
29+
30+
FROM miniconda3 AS py39
31+
32+
RUN conda install -y "python=3.9"
33+
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install

Dockerfile

Lines changed: 0 additions & 27 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 aiopy
3+
Copyright (c) 2022 - 2024 aiopy
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ if __name__ == '__main__':
167167

168168
## Requirements
169169

170-
- Python >= 3.7
170+
- Python >= 3.9
171171

172172
## Contributing
173173

aiodi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Container for the Dependency Injection in Python."""
2+
23
# pylint: skip-file
34
from .builder import ContainerBuilder
45
from .container import Container, ContainerKey

aiodi/builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
debug: bool = False,
3333
tool_key: str = 'aiodi',
3434
var_key: str = 'env', # Container retro-compatibility
35-
toml_decoder: Optional[TOMLDecoder] = None
35+
toml_decoder: Optional[TOMLDecoder] = None,
3636
) -> None:
3737
self._filenames = (
3838
[
@@ -55,7 +55,7 @@ def __init__(
5555
'variable': VariableResolver(),
5656
}
5757
self._decoders = {
58-
'toml': lambda path: (toml_decoder or lazy_toml_decoder())(path).get('tool', {}).get(tool_key, {}), # type: ignore
58+
'toml': lambda path: (toml_decoder or lazy_toml_decoder())(path).get('tool', {}).get(tool_key, {}),
5959
}
6060

6161
def map_items(items: Dict[str, Dict[str, Any]]) -> List[Tuple[str, Any, Dict[str, Any]]]:
@@ -67,7 +67,7 @@ def map_items(items: Dict[str, Dict[str, Any]]) -> List[Tuple[str, Any, Dict[str
6767
}.items()
6868
]
6969

70-
self._map_items = map_items # type: ignore
70+
self._map_items = map_items
7171

7272
def load(self) -> Container:
7373
extra: Dict[str, Any] = {

aiodi/container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def resolve_parameter(self, fn: Callable[['Container'], Any]) -> Tuple[int, Call
4747
return len(self._parameter_resolvers) - 1, fn
4848

4949
def resolve(self, items: List[Union[ContainerKey, Tuple[ContainerKey, _T, Dict[str, Any]]]]) -> None:
50-
items_ = list(map(self._sanitize_item_before_resolve, items))
50+
items_: List[Any] = list(map(self._sanitize_item_before_resolve, items))
5151
while items_:
5252
for index, item in enumerate(items_):
5353
# Check if already exist
@@ -68,7 +68,7 @@ def resolve(self, items: List[Union[ContainerKey, Tuple[ContainerKey, _T, Dict[s
6868
if kwargs is not None:
6969
if self.debug:
7070
logger.debug('Resolving {0}'.format(item[1]))
71-
inst = item[1](**kwargs) # type: ignore
71+
inst = item[1](**kwargs)
7272
if self.debug:
7373
logger.debug('Adding {0} - {1}'.format(item[0], item[1]))
7474
self.set(item[0], inst)
@@ -162,7 +162,7 @@ def _sanitize_item_before_resolve(
162162
if length == 2:
163163
return item[0], item[1], {}
164164
if length >= 3:
165-
return item[:3] # type: ignore
165+
return item[:3]
166166
raise ValueError('Tuple must be at least of one item')
167167

168168
def _resolve_or_postpone_item(

aiodi/resolver/service.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ def from_param_inspected_and_args(
168168
default=(
169169
arguments[str(param[0])]
170170
if str(param[0]) in arguments and arguments[str(param[0])].startswith('@')
171-
else None
172-
if param[1].default is Parameter.empty
173-
else param[1].default
171+
else None if param[1].default is Parameter.empty else param[1].default
174172
),
175173
)
176174

@@ -188,8 +186,8 @@ class ServiceResolver(Resolver[ServiceMetadata, Any]):
188186
@staticmethod
189187
def _define_service_type(name: str, typ: str, cls: str) -> Tuple[Type[Any], Type[Any]]:
190188
if typ is _SVC_DEFAULTS and cls is _SVC_DEFAULTS: # type: ignore
191-
cls = typ = import_module_and_get_attr(name=name) # type: ignore
192-
return typ, cls # type: ignore
189+
cls = typ = import_module_and_get_attr(name=name)
190+
return typ, cls
193191

194192
if typ is not _SVC_DEFAULTS: # type: ignore
195193
typ = import_module_and_get_attr(name=typ) # type: ignore
@@ -198,7 +196,7 @@ def _define_service_type(name: str, typ: str, cls: str) -> Tuple[Type[Any], Type
198196

199197
if typ is _SVC_DEFAULTS: # type: ignore
200198
try:
201-
typ = import_module_and_get_attr(name=name) # type: ignore
199+
typ = import_module_and_get_attr(name=name)
202200
except Exception:
203201
typ = cls
204202
if cls is _SVC_DEFAULTS: # type: ignore
@@ -226,7 +224,7 @@ def extract_metadata(self, data: Dict[str, Any], extra: Dict[str, Any]) -> Servi
226224
clazz=clazz,
227225
arguments=kwargs,
228226
params=[
229-
ServiceMetadata.ParameterMetadata.from_param_inspected_and_args(param=param, arguments=kwargs)
227+
ServiceMetadata.ParameterMetadata.from_param_inspected_and_args(param=param, arguments=kwargs) # type: ignore
230228
for param in signature(clazz).parameters.items()
231229
],
232230
defaults=defaults,

aiodi/resolver/variable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def extract_metadata(
7070
name=key,
7171
value=val,
7272
matches=[
73-
VariableMetadata.MatchMetadata.from_match(match=match)
73+
VariableMetadata.MatchMetadata.from_match(match=match) # type: ignore
7474
for match in self._metadata_matches(key=key, val=val)
7575
],
7676
)
@@ -93,7 +93,7 @@ def parse_value(
9393
if typ_val is None:
9494
# can only concatenate str to str
9595
return typ_val
96-
if metadata_.default is _VAR_DEFAULTS and typ_val == metadata_.default:
96+
if metadata_.default is _VAR_DEFAULTS and typ_val == metadata_.default: # type: ignore
9797
raise EnvironmentVariableNotFound(name=metadata_.source_name)
9898
elif metadata_.source_kind == 'var':
9999
if metadata_.source_name not in _variables:

aiodi/toml.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
from pathlib import Path
2-
from typing import Any, Callable, Dict, MutableMapping, Union
2+
from typing import Any, Callable, Dict, MutableMapping, Union, cast
33

44
TOMLDecoded = Union[MutableMapping[str, Any], Dict[str, Any]]
55
TOMLPath = Union[str, Path]
66
TOMLDecoder = Callable[[TOMLPath], TOMLDecoded]
77

88

99
def _decoder_from_builtin_lib() -> TOMLDecoder:
10-
from tomllib import load # type: ignore
10+
from tomllib import load
1111

1212
def decorator(path: TOMLPath) -> TOMLDecoded:
1313
with open(path, 'rb') as file:
14-
return load(file) # type: ignore
14+
return cast(TOMLDecoded, load(file))
1515

1616
return decorator
1717

1818

1919
def _decoder_from_pytomlpp_lib() -> TOMLDecoder:
20-
from pytomlpp import load # type: ignore
20+
from pytomlpp import load
2121

2222
return load # type: ignore
2323

2424

2525
def _decoder_from_rtoml_lib() -> TOMLDecoder:
26-
from rtoml import load # type: ignore
26+
from rtoml import load
2727

2828
def decorator(path: TOMLPath) -> TOMLDecoded:
2929
with open(path, 'r', encoding='utf-8') as file:
@@ -37,13 +37,13 @@ def _decoder_from_tomli_lib() -> TOMLDecoder:
3737

3838
def decorator(path: TOMLPath) -> TOMLDecoded:
3939
with open(path, 'rb') as file:
40-
return load(file)
40+
return cast(TOMLDecoded, load(file))
4141

4242
return decorator
4343

4444

4545
def _decoder_from_pytoml_lib() -> TOMLDecoder:
46-
from pytoml import load # type: ignore
46+
from pytoml import load
4747

4848
def decorator(path: TOMLPath) -> TOMLDecoded:
4949
with open(path, 'rb') as file:
@@ -59,7 +59,7 @@ def _decoder_from_toml_lib() -> TOMLDecoder:
5959

6060

6161
def _decoder_from_qtoml_lib() -> TOMLDecoder:
62-
from qtoml import load # type: ignore
62+
from qtoml import load
6363

6464
def decorator(path: TOMLPath) -> TOMLDecoded:
6565
with open(path, 'r', encoding='utf-8') as file:

compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
aiodi:
3+
build:
4+
context: .
5+
dockerfile: Containerfile
6+
target: py39
7+
# target: py310
8+
# target: py311
9+
# target: py312
10+
image: ghcr.io/aiopy/python-aiodi:py39-${VERSION:-latest}
11+
# image: ghcr.io/aiopy/python-aiodi:py310-${VERSION:-latest}
12+
# image: ghcr.io/aiopy/python-aiodi:py311-${VERSION:-latest}
13+
# image: ghcr.io/aiopy/python-aiodi:py312-${VERSION:-latest}
14+
volumes:
15+
- .:/app

docker-compose.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs_src/docs/en/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Key Features:
1010

1111
## Requirements
1212

13-
- Python 3.7+
13+
- Python 3.9+
1414

1515
## Installation
1616

docs_src/docs/es/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Funcionalidades clave:
1010

1111
## Requisitos
1212

13-
- Python 3.7+
13+
- Python 3.9+
1414

1515
## Instalación
1616

docs_src/generated/en/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ <h1 id="aiodi">AIODI</h1>
418418
</ul>
419419
<h2 id="requirements">Requirements</h2>
420420
<ul>
421-
<li>Python 3.7+</li>
421+
<li>Python 3.9+</li>
422422
</ul>
423423
<h2 id="installation">Installation</h2>
424424
<div class="highlight"><pre><span></span><code>python3 -m pip install aiodi
@@ -609,4 +609,4 @@ <h2 id="license">License</h2>
609609

610610

611611
</body>
612-
</html>
612+
</html>

0 commit comments

Comments
 (0)