Read about our upcoming Code of Conduct on this issue

Commit f1b27e61 authored by Pierre Augier's avatar Pierre Augier
Browse files

Bugfix conserve OMP comments

parent a5af8fa802ce
......@@ -6,6 +6,11 @@ Future
- Alternative syntax for blocks (see `issue #29
<https://bitbucket.org/fluiddyn/fluidpythran/issues/29>`_)
0.1.7 (2018-12-18)
------------------
- Bugfix: keep OMP comments!
0.1.6 (2018-12-14)
------------------
......
__version__ = "0.1.6"
__version__ = "0.1.7"
try:
from pyfiglet import figlet_format
......
......@@ -148,7 +148,8 @@ class SchedulerPopen:
logger.warning(
f"Do not pythranize {path} because it seems up-to-date "
"(but the compilation options may have changed). "
"You can force the compilation with the option -f.")
"You can force the compilation with the option -f."
)
return
logger.info(f"Schedule pythranization of file {path}")
......
......@@ -154,7 +154,7 @@ def parse_py_code(code: str):
has_to_find_code_block = "in block"
code_blocks[name_block] = []
logger.debug((tok_name[toknum], tokval))
# logger.debug((tok_name[toknum], tokval))
return (
blocks,
......
......@@ -54,6 +54,11 @@ from typing import Callable
import astunparse
try:
import black
except ImportError:
black = False
try:
import pythran
except ImportError:
......@@ -173,13 +178,23 @@ class TypeHintRemover(ast.NodeTransformer):
def strip_typehints(source):
"""Strip the type hints from a function"""
if black:
source = black.format_str(source, line_length=82)
# parse the source code into an AST
parsed_source = ast.parse(source)
# remove all type annotations, function return type definitions
# and import statements from 'typing'
transformed = TypeHintRemover().visit(parsed_source)
# convert the AST back to source code
return astunparse.unparse(transformed)
striped_code = astunparse.unparse(transformed)
# bad hack to conserve the comments...
sep = ":(\n)+ "
head = re.split(sep, striped_code, maxsplit=1)[0]
body = re.split(sep, source, maxsplit=1)[-1]
return head + ":\n " + body
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