Skip to content

Commit

Permalink
chore: support Python 3.12 (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: SdgJlbl <[email protected]>
  • Loading branch information
SdgJlbl authored Jul 23, 2024
1 parent 4ec9166 commit 09d4e56
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12
- name: Install Hatch
run: pipx install hatch
- name: Build dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.11
python-version: 3.12
- name: Install tools
run: pip install flake8
- name: Lint
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
license = { file = "LICENSE" }
authors = [{ name = "Owkin, Inc." }]
Expand Down
2 changes: 1 addition & 1 deletion substratools/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from substratools import exceptions
from substratools import opener
from substratools import utils
from substratools.exceptions import FunctionNotFoundError
from substratools.exceptions import ExistingRegisteredFunctionError
from substratools.exceptions import FunctionNotFoundError
from substratools.task_resources import StaticInputIdentifiers
from substratools.task_resources import TaskResources
from substratools.workspace import FunctionWorkspace
Expand Down
2 changes: 1 addition & 1 deletion substratools/task_resources.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
from enum import Enum
from typing import Dict
from typing import List
from typing import Optional
from typing import Union

from substratools import exceptions
from enum import Enum


class StaticInputIdentifiers(str, Enum):
Expand Down
5 changes: 3 additions & 2 deletions substratools/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import imp
import importlib
import importlib.util
import inspect
import logging
import os
Expand Down Expand Up @@ -66,7 +66,8 @@ def wrapper(*args, **kwargs):
def import_module(module_name, code):
if module_name in sys.modules:
logging.warning("Module {} will be overwritten".format(module_name))
module = imp.new_module(module_name)
spec = importlib.util.spec_from_loader(module_name, loader=None, origin=module_name)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
exec(code, module.__dict__)

Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import os

import sys
from pathlib import Path
from uuid import uuid4
Expand All @@ -9,8 +8,8 @@

from substratools.task_resources import TaskResources
from substratools.utils import import_module
from tests.utils import OutputIdentifiers
from substratools.workspace import FunctionWorkspace
from tests.utils import OutputIdentifiers


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions tests/test_aggregatealgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import pytest

from substratools import function
from substratools import exceptions
from substratools import function
from substratools import opener
from substratools.task_resources import TaskResources
from substratools.workspace import FunctionWorkspace
from tests import utils
from tests.utils import InputIdentifiers
from tests.utils import OutputIdentifiers
from tests import utils


@pytest.fixture(autouse=True)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_compositealgo.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import json
import os

from typing import Any
from typing import Optional
from typing import TypedDict

import pytest

from substratools import function
from substratools import exceptions
from substratools import function
from substratools import opener
from substratools.task_resources import TaskResources
from substratools.workspace import FunctionWorkspace
from substratools import opener
from tests import utils
from tests.utils import InputIdentifiers
from tests.utils import OutputIdentifiers
Expand Down
5 changes: 3 additions & 2 deletions tests/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
import shutil
from os import PathLike
from pathlib import Path
from typing import Any, Tuple
from typing import Any
from typing import List
from typing import Optional
from typing import Tuple
from typing import TypedDict

import pytest

from substratools import function
from substratools import exceptions
from substratools import function
from substratools import opener
from substratools.task_resources import StaticInputIdentifiers
from substratools.task_resources import TaskResources
Expand Down
4 changes: 2 additions & 2 deletions tests/test_opener.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import pytest

from substratools import exceptions
from substratools.opener import load_from_module
from substratools.opener import Opener
from substratools.opener import OpenerWrapper
from substratools.opener import load_from_module
from substratools.utils import import_module
from substratools.utils import load_interface_from_module
from substratools.workspace import DEFAULT_INPUT_DATA_FOLDER_PATH
from substratools.opener import OpenerWrapper


@pytest.fixture
Expand Down
8 changes: 5 additions & 3 deletions tests/test_task_resources.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from substratools.task_resources import TaskResources
from substratools.task_resources import StaticInputIdentifiers
import json

import pytest

from substratools.exceptions import InvalidCLIError
from substratools.exceptions import InvalidInputOutputsError
import json
from substratools.task_resources import StaticInputIdentifiers
from substratools.task_resources import TaskResources

_VALID_RESOURCES = [
{"id": "foo", "value": "bar", "multiple": True},
Expand Down

0 comments on commit 09d4e56

Please sign in to comment.