Skip to content

chore(*): Remove Python 3.7 and Python 3.8 support and add Python 3.11, Python 3.12 and Python 3.13 support #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
env:
VERSION: ${{ github.event.inputs.release_version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.13.0-rc.2'
- name: version
run: sed -i "s/__version__ = '.*'/__version__ = '$VERSION'/g" aiodi/__init__.py
- name: deps
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13.0-rc.2' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: deps
Expand Down
33 changes: 33 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM docker.io/continuumio/miniconda3:latest AS miniconda3

WORKDIR /app

RUN conda install -y --download-only "python=3.12" && \
conda install -y --download-only "python=3.11" && \
conda install -y --download-only "python=3.10" && \
conda install -y --download-only "python=3.9"

COPY . ./

ENTRYPOINT ["python3"]
CMD ["run-script"]

FROM miniconda3 AS py312

RUN conda install -y "python=3.12"
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install

FROM miniconda3 AS py311

RUN conda install -y "python=3.11"
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install

FROM miniconda3 AS py310

RUN conda install -y "python=3.10"
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install

FROM miniconda3 AS py39

RUN conda install -y "python=3.9"
RUN --mount=type=cache,target=/root/.cache/pip python3 run-script dev-install
27 changes: 0 additions & 27 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 aiopy
Copyright (c) 2022 - 2024 aiopy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ if __name__ == '__main__':

## Requirements

- Python >= 3.7
- Python >= 3.9

## Contributing

Expand Down
1 change: 1 addition & 0 deletions aiodi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Container for the Dependency Injection in Python."""

# pylint: skip-file
from .builder import ContainerBuilder
from .container import Container, ContainerKey
Expand Down
6 changes: 3 additions & 3 deletions aiodi/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
debug: bool = False,
tool_key: str = 'aiodi',
var_key: str = 'env', # Container retro-compatibility
toml_decoder: Optional[TOMLDecoder] = None
toml_decoder: Optional[TOMLDecoder] = None,
) -> None:
self._filenames = (
[
Expand All @@ -55,7 +55,7 @@ def __init__(
'variable': VariableResolver(),
}
self._decoders = {
'toml': lambda path: (toml_decoder or lazy_toml_decoder())(path).get('tool', {}).get(tool_key, {}), # type: ignore
'toml': lambda path: (toml_decoder or lazy_toml_decoder())(path).get('tool', {}).get(tool_key, {}),
}

def map_items(items: Dict[str, Dict[str, Any]]) -> List[Tuple[str, Any, Dict[str, Any]]]:
Expand All @@ -67,7 +67,7 @@ def map_items(items: Dict[str, Dict[str, Any]]) -> List[Tuple[str, Any, Dict[str
}.items()
]

self._map_items = map_items # type: ignore
self._map_items = map_items

def load(self) -> Container:
extra: Dict[str, Any] = {
Expand Down
6 changes: 3 additions & 3 deletions aiodi/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def resolve_parameter(self, fn: Callable[['Container'], Any]) -> Tuple[int, Call
return len(self._parameter_resolvers) - 1, fn

def resolve(self, items: List[Union[ContainerKey, Tuple[ContainerKey, _T, Dict[str, Any]]]]) -> None:
items_ = list(map(self._sanitize_item_before_resolve, items))
items_: List[Any] = list(map(self._sanitize_item_before_resolve, items))
while items_:
for index, item in enumerate(items_):
# Check if already exist
Expand All @@ -68,7 +68,7 @@ def resolve(self, items: List[Union[ContainerKey, Tuple[ContainerKey, _T, Dict[s
if kwargs is not None:
if self.debug:
logger.debug('Resolving {0}'.format(item[1]))
inst = item[1](**kwargs) # type: ignore
inst = item[1](**kwargs)
if self.debug:
logger.debug('Adding {0} - {1}'.format(item[0], item[1]))
self.set(item[0], inst)
Expand Down Expand Up @@ -162,7 +162,7 @@ def _sanitize_item_before_resolve(
if length == 2:
return item[0], item[1], {}
if length >= 3:
return item[:3] # type: ignore
return item[:3]
raise ValueError('Tuple must be at least of one item')

def _resolve_or_postpone_item(
Expand Down
12 changes: 5 additions & 7 deletions aiodi/resolver/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def from_param_inspected_and_args(
default=(
arguments[str(param[0])]
if str(param[0]) in arguments and arguments[str(param[0])].startswith('@')
else None
if param[1].default is Parameter.empty
else param[1].default
else None if param[1].default is Parameter.empty else param[1].default
),
)

Expand All @@ -188,8 +186,8 @@ class ServiceResolver(Resolver[ServiceMetadata, Any]):
@staticmethod
def _define_service_type(name: str, typ: str, cls: str) -> Tuple[Type[Any], Type[Any]]:
if typ is _SVC_DEFAULTS and cls is _SVC_DEFAULTS: # type: ignore
cls = typ = import_module_and_get_attr(name=name) # type: ignore
return typ, cls # type: ignore
cls = typ = import_module_and_get_attr(name=name)
return typ, cls

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

if typ is _SVC_DEFAULTS: # type: ignore
try:
typ = import_module_and_get_attr(name=name) # type: ignore
typ = import_module_and_get_attr(name=name)
except Exception:
typ = cls
if cls is _SVC_DEFAULTS: # type: ignore
Expand Down Expand Up @@ -226,7 +224,7 @@ def extract_metadata(self, data: Dict[str, Any], extra: Dict[str, Any]) -> Servi
clazz=clazz,
arguments=kwargs,
params=[
ServiceMetadata.ParameterMetadata.from_param_inspected_and_args(param=param, arguments=kwargs)
ServiceMetadata.ParameterMetadata.from_param_inspected_and_args(param=param, arguments=kwargs) # type: ignore
for param in signature(clazz).parameters.items()
],
defaults=defaults,
Expand Down
4 changes: 2 additions & 2 deletions aiodi/resolver/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def extract_metadata(
name=key,
value=val,
matches=[
VariableMetadata.MatchMetadata.from_match(match=match)
VariableMetadata.MatchMetadata.from_match(match=match) # type: ignore
for match in self._metadata_matches(key=key, val=val)
],
)
Expand All @@ -93,7 +93,7 @@ def parse_value(
if typ_val is None:
# can only concatenate str to str
return typ_val
if metadata_.default is _VAR_DEFAULTS and typ_val == metadata_.default:
if metadata_.default is _VAR_DEFAULTS and typ_val == metadata_.default: # type: ignore
raise EnvironmentVariableNotFound(name=metadata_.source_name)
elif metadata_.source_kind == 'var':
if metadata_.source_name not in _variables:
Expand Down
16 changes: 8 additions & 8 deletions aiodi/toml.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
from pathlib import Path
from typing import Any, Callable, Dict, MutableMapping, Union
from typing import Any, Callable, Dict, MutableMapping, Union, cast

TOMLDecoded = Union[MutableMapping[str, Any], Dict[str, Any]]
TOMLPath = Union[str, Path]
TOMLDecoder = Callable[[TOMLPath], TOMLDecoded]


def _decoder_from_builtin_lib() -> TOMLDecoder:
from tomllib import load # type: ignore
from tomllib import load

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

return decorator


def _decoder_from_pytomlpp_lib() -> TOMLDecoder:
from pytomlpp import load # type: ignore
from pytomlpp import load

return load # type: ignore


def _decoder_from_rtoml_lib() -> TOMLDecoder:
from rtoml import load # type: ignore
from rtoml import load

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

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

return decorator


def _decoder_from_pytoml_lib() -> TOMLDecoder:
from pytoml import load # type: ignore
from pytoml import load

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


def _decoder_from_qtoml_lib() -> TOMLDecoder:
from qtoml import load # type: ignore
from qtoml import load

def decorator(path: TOMLPath) -> TOMLDecoded:
with open(path, 'r', encoding='utf-8') as file:
Expand Down
15 changes: 15 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
aiodi:
build:
context: .
dockerfile: Containerfile
target: py39
# target: py310
# target: py311
# target: py312
image: ghcr.io/aiopy/python-aiodi:py39-${VERSION:-latest}
# image: ghcr.io/aiopy/python-aiodi:py310-${VERSION:-latest}
# image: ghcr.io/aiopy/python-aiodi:py311-${VERSION:-latest}
# image: ghcr.io/aiopy/python-aiodi:py312-${VERSION:-latest}
volumes:
- .:/app
11 changes: 0 additions & 11 deletions docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs_src/docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Key Features:

## Requirements

- Python 3.7+
- Python 3.9+

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docs_src/docs/es/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Funcionalidades clave:

## Requisitos

- Python 3.7+
- Python 3.9+

## Instalación

Expand Down
4 changes: 2 additions & 2 deletions docs_src/generated/en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ <h1 id="aiodi">AIODI</h1>
</ul>
<h2 id="requirements">Requirements</h2>
<ul>
<li>Python 3.7+</li>
<li>Python 3.9+</li>
</ul>
<h2 id="installation">Installation</h2>
<div class="highlight"><pre><span></span><code>python3 -m pip install aiodi
Expand Down Expand Up @@ -609,4 +609,4 @@ <h2 id="license">License</h2>


</body>
</html>
</html>
Loading