Skip to content

Commit

Permalink
Feature/add python3.12 drop python3.7 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzhenzhera authored Oct 9, 2023
1 parent 0e7adb3 commit 73cfde1
Show file tree
Hide file tree
Showing 18 changed files with 457 additions and 518 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -34,8 +34,6 @@ jobs:
matrix:
include:
# test python versions
- python: "3.7"
os: ubuntu-latest
- python: "3.8"
os: ubuntu-latest
- python: "3.9"
Expand All @@ -44,6 +42,8 @@ jobs:
os: ubuntu-latest
- python: "3.11"
os: ubuntu-latest
- python: "3.12"
os: ubuntu-latest
# test OSs
- python: "3.x"
os: macos-latest
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ init: .clean .init
@echo ---- 🔧 Re-initialized project ----

lint: .init
poetry run ruff --fix di tests
poetry run black di tests
poetry run ruff --fix di tests docs_src
poetry run black di tests docs_src
poetry run mypy di tests

test: .init
Expand Down
7 changes: 1 addition & 6 deletions di/_container.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import inspect
import sys
import typing
from contextlib import AsyncExitStack, ExitStack, contextmanager
from types import TracebackType
Expand All @@ -12,6 +11,7 @@
Generic,
Iterable,
Mapping,
Protocol,
Sequence,
TypeVar,
cast,
Expand Down Expand Up @@ -57,11 +57,6 @@
WiringError,
)

if sys.version_info < (3, 8): # pragma: no cover
from typing_extensions import Protocol
else: # pragma: no cover
from typing import Protocol


class BindHook(Protocol):
def __call__(
Expand Down
4 changes: 2 additions & 2 deletions di/_utils/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
overload,
)

if sys.version_info < (3, 10):
if sys.version_info < (3, 10): # pragma: no cover
from typing_extensions import ParamSpec
else:
else: # pragma: no cover
from typing import ParamSpec

import anyio
Expand Down
4 changes: 2 additions & 2 deletions di/_utils/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import sys
from typing import Any, Callable, Dict, Mapping, Optional, Union

if sys.version_info < (3, 9):
if sys.version_info < (3, 9): # pragma: no cover
from typing_extensions import Annotated, get_args, get_origin, get_type_hints
else:
else: # pragma: no cover
from typing import Annotated, get_args, get_origin, get_type_hints

from di._utils.types import Some
Expand Down
9 changes: 1 addition & 8 deletions di/_utils/types.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import sys
from dataclasses import dataclass
from types import TracebackType
from typing import Generic, Optional, Type, TypeVar, Union

if sys.version_info < (3, 8): # pragma: no cover
from typing_extensions import Protocol
else: # pragma: no cover
from typing import Protocol

from typing import Generic, Optional, Protocol, Type, TypeVar, Union

T = TypeVar("T")

Expand Down
10 changes: 0 additions & 10 deletions di/_utils/typing.py

This file was deleted.

17 changes: 10 additions & 7 deletions di/api/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import inspect
import sys
from typing import Any, Generic, List, NamedTuple, Optional, TypeVar

if sys.version_info < (3, 8):
from typing_extensions import Protocol, runtime_checkable
else:
from typing import Protocol, runtime_checkable
from typing import (
Any,
Generic,
List,
NamedTuple,
Optional,
Protocol,
TypeVar,
runtime_checkable,
)

from di._utils.types import CacheKey
from di.api.providers import DependencyProviderType
Expand Down
8 changes: 1 addition & 7 deletions di/api/executor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from __future__ import annotations

import sys
from typing import Iterable, Union

if sys.version_info < (3, 8):
from typing_extensions import Protocol
else:
from typing import Protocol
from typing import Iterable, Protocol, Union

from di._task import AsyncTask, ExecutionState, SyncTask

Expand Down
6 changes: 3 additions & 3 deletions di/typing.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import sys
from typing import Generator, Type, TypeVar

if sys.version_info < (3, 9):
if sys.version_info < (3, 9): # pragma: no cover
from typing_extensions import Annotated, get_args, get_origin
else:
else: # pragma: no cover
from typing import Annotated, get_args, get_origin

from di._utils.inspect import get_parameters

__all__ = ("get_parameters", "get_markers_from_annotation")
__all__ = ("Annotated", "get_parameters", "get_markers_from_annotation")


T = TypeVar("T")
Expand Down
7 changes: 1 addition & 6 deletions docs_src/bind_as_a_dep.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import sys
from dataclasses import dataclass

if sys.version_info < (3, 8):
from typing_extensions import Protocol
else:
from typing import Protocol
from typing import Protocol

from di import Container, bind_by_type
from di.dependent import Dependent
Expand Down
2 changes: 1 addition & 1 deletion docs_src/solved_dependent.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def web_framework():

dependencies = solved.dag.keys() - {solved.dependency}
assert all(isinstance(item, Dependent) for item in dependencies)
assert set(dependent.call for dependent in dependencies) == {Request, MyClass}
assert {dependent.call for dependent in dependencies} == {Request, MyClass}


# User code
Expand Down
Loading

0 comments on commit 73cfde1

Please sign in to comment.