Skip to content

Commit

Permalink
downgrade syntax (change | to Union) to support Python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainp committed Aug 14, 2024
1 parent 34e1d21 commit b874f2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions smrt/core/lib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from typing import Type
from typing import Type, Union
import os

from collections.abc import Sequence
Expand Down Expand Up @@ -57,7 +57,7 @@ def is_sequence(x):
) and not isinstance(x, str)


def class_specializer(domain: str, cls: str | Type, **options) -> Type:
def class_specializer(domain: str, cls: Union[str, Type], **options) -> Type:
"""Return a subclass of cls (imported from the domain if cls is a string) that use the provided "options" for __init__. This is
equivalent to functools.partial but for a class.
Expand Down
6 changes: 3 additions & 3 deletions smrt/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
Both are equivalent and there is no plan to depreciate the original approach that has some nice use-cases.
"""

from typing import Type
from typing import Type, Union
from collections.abc import Sequence, Mapping
from dataclasses import dataclass
import itertools
Expand Down Expand Up @@ -148,7 +148,7 @@ def make_model(
return Model(emmodel, rtsolver, emmodel_options=emmodel_options, rtsolver_options=rtsolver_options)


def rtsolver(rtsolver_class: str | Type, **options) -> Type:
def rtsolver(rtsolver_class: Union[str, Type], **options) -> Type:
"""return a rtsolver subclass of cls (either given as a string or a class) where the provided options are applied to __init__.
This function provides an alternative to setting `rtsolver_options` in :py:func:`make_model`).
Expand All @@ -158,7 +158,7 @@ def rtsolver(rtsolver_class: str | Type, **options) -> Type:
return lib.class_specializer('rtsolver', rtsolver_class, **options)


def emmodel(emmodel_class: str | Type, **options) -> Type:
def emmodel(emmodel_class: Union[str, Type], **options) -> Type:
"""return a emmodel subclass of cls (either given as a string or a class) where the provided options are applied to __init__.
This function provides an alternative to setting `emmodel_options` in :py:func:`make_model`).
Expand Down

0 comments on commit b874f2b

Please sign in to comment.