User-defined types in signatures in comments
from transonic import boost
T = float
# transonic def func(T)
@boost
def func(a):
return 2 * a
leads to
Traceback (most recent call last):
File "/home/pierre/.pyenv/versions/3.8.2/bin/transonic", line 11, in <module>
load_entry_point('transonic', 'console_scripts', 'transonic')()
File "/home/pierre/Dev/transonic/transonic/run.py", line 85, in run
backend.make_backend_files(paths, force=args.force)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 76, in make_backend_files
path_out = self.make_backend_file(path, analyse, force=force)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 131, in make_backend_file
code_backend, codes_ext, code_header = self._make_backend_code(
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 189, in _make_backend_code
signatures_func = self._make_header_1_function(fdef, annotations)
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 460, in _make_header_1_function
return self._make_header_from_fdef_annotations(
File "/home/pierre/Dev/transonic/transonic/backends/base.py", line 472, in _make_header_from_fdef_annotations
compute_signatures_from_typeobjects(annot, self.type_formatter)
File "/home/pierre/Dev/transonic/transonic/signatures.py", line 56, in compute_signatures_from_typeobjects
type_ = str2type(type_)
File "/home/pierre/Dev/transonic/transonic/typing.py", line 922, in str2type
raise ValueError(f"Can't determine the Transonic type from '{str_type}'")
ValueError: Can't determine the Transonic type from 'T'
It's silly because it works fine with blocs! And it can be very useful! See fluidsim!156 (merged)
Edited by Pierre Augier