Commit 3153c9c01ff by Pierre Augier

Use autopep8 if black is not importable

parent d6b931024ff
import black
import gast
import numpy as np
from .for_test_exterior_import_jit_2 import func_import_2
......@@ -19,5 +19,5 @@ def func_import2():
return const + np.pi - np.pi
def use_black():
print(black)
def use_gast():
print(gast)
import black
import gast
import numpy as np
......@@ -10,5 +10,5 @@ def func_import_2():
return const
def use_black():
print(black)
def use_gast():
print(gast)
import black
import gast
import numpy as np
from exterior_import_boost_2 import func_import_2
......@@ -11,5 +11,5 @@ def func_import():
return const + func_import_2() + np.pi - np.pi
def use_black():
print(black)
def use_gast():
print(gast)
import black
import gast
import numpy as np
......@@ -10,5 +10,5 @@ def func_import_2():
return const
def use_black():
print(black)
def use_gast():
print(gast)
......@@ -37,7 +37,7 @@ pack_dir = here / pack_name
version = run_path(pack_name + "/_version.py")
__version__ = version["__version__"]
install_requires = ["transonic", "black", "numpy", "matplotlib", "numba"]
install_requires = ["transonic", "numpy", "matplotlib", "numba"]
relative_paths = ["calcul.py"]
make_backend_files(
......
......@@ -37,7 +37,7 @@ pack_dir = here / pack_name
version = run_path(pack_name + "/_version.py")
__version__ = version["__version__"]
install_requires = ["transonic", "black", "numpy", "matplotlib"]
install_requires = ["transonic", "numpy", "matplotlib"]
relative_paths = ["util.py", "calcul.py"]
make_backend_files([pack_dir / path for path in relative_paths])
......
......@@ -16,6 +16,7 @@ install_requires =
gast
beniget
# black # avoid this dependency for now (see https://github.com/ambv/black/issues/552)
autopep8
setup_requires = setuptools
[options.extras_require]
......
......@@ -64,10 +64,10 @@ try:
# since black is still beta (in 03/2019), we can not impose a version :-(
import black
except ImportError:
import autopep8
def format_str(src_contents):
print("Please install black (pip install black) to use Transonic")
return src_contents
return autopep8.fix_code(src_contents)
else:
......@@ -237,15 +237,11 @@ def strip_typehints(source):
return striped_code
def make_code_from_fdef_node(fdef, black=True):
def make_code_from_fdef_node(fdef):
transformed = TypeHintRemover().visit(fdef)
# convert the AST back to source code
code = extast.unparse(transformed)
if black:
code = format_str(code)
return code
return format_str(code)
def get_ipython_input(last=True):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment