Skip to content

Commit

Permalink
Create frozenset SUPPORTED_BACKENDS to avoid repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinvis committed Mar 14, 2024
1 parent ac3ae9c commit e6dae54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/transonic/analyses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .parser import parse_transonic_def_commands
from .objects_from_str import replace_strings_by_objects
from . import extast
from ..config import SUPPORTED_BACKENDS


__all__ = ["print_dumped", "print_unparsed"]
Expand Down Expand Up @@ -88,7 +89,7 @@ def get_decorated_dicts(

kinds = ("functions", "functions_ext", "methods", "classes")

backend_names = ("__all__", "pythran", "cython", "numba", "python")
backend_names = ("__all__", *SUPPORTED_BACKENDS)
decorated_dicts = {
kind: {name: {} for name in backend_names} for kind in kinds
}
Expand Down
5 changes: 2 additions & 3 deletions src/transonic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from warnings import warn

path_root = Path(os.environ.get("TRANSONIC_DIR", Path.home() / ".transonic"))

SUPPORTED_BACKENDS = frozenset(("pythran", "cython", "jax", "numba", "python"))

def strtobool(value):
"""Convert a string representation of truth to true (1) or false (0).
Expand Down Expand Up @@ -75,8 +75,7 @@ def set_backend(backend: str):
"""Set the "global variable" backend_default"""

backend = backend.lower()
supported_backends = {"pythran", "cython", "jax", "numba", "python"}
if backend not in supported_backends:
if backend not in SUPPORTED_BACKENDS:
raise ValueError(f"backend {backend} not supported")

global backend_default, backend_set_by_user
Expand Down

0 comments on commit e6dae54

Please sign in to comment.