From 661e8395026efdc42dab0f49b8f27aa1f1c9c35f Mon Sep 17 00:00:00 2001 From: paugier Date: Tue, 4 Jun 2024 17:14:09 +0200 Subject: [PATCH] Format with black --- data_tests/test_packaging/base.py | 1 + src/transonic/analyses/__init__.py | 6 +++--- src/transonic/analyses/util.py | 1 + src/transonic/backends/cython.py | 1 + src/transonic/backends/jax.py | 3 ++- src/transonic/config.py | 1 + src/transonic/progress.py | 1 + src/transonic/typing.py | 1 + src/transonic_cl/init_meson.py | 5 ++--- 9 files changed, 13 insertions(+), 7 deletions(-) diff --git a/data_tests/test_packaging/base.py b/data_tests/test_packaging/base.py index 8ff2207..b56f7dd 100644 --- a/data_tests/test_packaging/base.py +++ b/data_tests/test_packaging/base.py @@ -1,4 +1,5 @@ """A pure Python module containing a few functions""" + import numpy as np diff --git a/src/transonic/analyses/__init__.py b/src/transonic/analyses/__init__.py index a431841..975e73b 100644 --- a/src/transonic/analyses/__init__.py +++ b/src/transonic/analyses/__init__.py @@ -424,9 +424,9 @@ def analyse_aot(code, pathfile): annotations["__locals__"][name_func] = annotations_locals if fdef.returns: - annotations["__returns__"][ - name_func - ] = extract_returns_annotation(fdef.returns, namespace) + annotations["__returns__"][name_func] = ( + extract_returns_annotation(fdef.returns, namespace) + ) for signatures in annotations["__in_comments__"].values(): replace_strings_by_objects(signatures, module, ancestors, udc, duc) diff --git a/src/transonic/analyses/util.py b/src/transonic/analyses/util.py index 16a52d7..0e3fce2 100644 --- a/src/transonic/analyses/util.py +++ b/src/transonic/analyses/util.py @@ -2,6 +2,7 @@ ============================= """ + import re from pathlib import Path from textwrap import dedent diff --git a/src/transonic/backends/cython.py b/src/transonic/backends/cython.py index bbb971d..21295a3 100644 --- a/src/transonic/backends/cython.py +++ b/src/transonic/backends/cython.py @@ -17,6 +17,7 @@ :private-members: """ + import copy import inspect diff --git a/src/transonic/backends/jax.py b/src/transonic/backends/jax.py index 4669b60..8caf29d 100644 --- a/src/transonic/backends/jax.py +++ b/src/transonic/backends/jax.py @@ -32,7 +32,8 @@ def add_jax_comments(code): # Replace `import numpy as np` -> `import jax.numpy as np` if isinstance(node, gast.Import): if (alias := node.names[0]).name == "numpy": - node = gast.Import([gast.alias(name="jax.numpy", asname=alias.asname or alias.name)]) + g_alias = gast.alias(name="jax.numpy", asname=alias.asname or alias.name) + node = gast.Import([g_alias]) # Replace `from numpy import eye` -> `from jax.numpy import eye` elif isinstance(node, gast.ImportFrom): diff --git a/src/transonic/config.py b/src/transonic/config.py index 032f8d4..b592c7f 100644 --- a/src/transonic/config.py +++ b/src/transonic/config.py @@ -49,6 +49,7 @@ 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). diff --git a/src/transonic/progress.py b/src/transonic/progress.py index e620a7c..a13ed20 100644 --- a/src/transonic/progress.py +++ b/src/transonic/progress.py @@ -5,6 +5,7 @@ logging messages. """ + from transonic.log import logger diff --git a/src/transonic/typing.py b/src/transonic/typing.py index 68934dd..128cd65 100644 --- a/src/transonic/typing.py +++ b/src/transonic/typing.py @@ -66,6 +66,7 @@ :private-members: """ + import re from enum import Enum, auto import itertools diff --git a/src/transonic_cl/init_meson.py b/src/transonic_cl/init_meson.py index 6a9cce7..aba456a 100644 --- a/src/transonic_cl/init_meson.py +++ b/src/transonic_cl/init_meson.py @@ -21,9 +21,9 @@ def process_directory(path_dir, path_pack=None): if path_pack is None: path_pack = path_dir print(f"Process {path_dir}") - subdir=path_pack.name + subdir = path_pack.name else: - subdir=PurePosixPath(path_dir.relative_to(path_pack.parent)) + subdir = PurePosixPath(path_dir.relative_to(path_pack.parent)) print(f"Process subdir {subdir}") names_py = sorted(path.name for path in path_dir.glob("*.py")) @@ -77,4 +77,3 @@ def main(): sys.exit(1) process_directory(path_pack) -