diff --git a/pyproject.toml b/pyproject.toml index 4e07239..df165cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "string-to-code" -version = "0.2.11" +version = "0.2.12" description = "Generates a piece of messy code in a given language displaying a given string " authors = ["piotr.idzik "] readme = "./string_to_code/README.md" diff --git a/string_to_code/c_like_utils.py b/string_to_code/c_like_utils.py index 4cf01f6..54ecbe6 100644 --- a/string_to_code/c_like_utils.py +++ b/string_to_code/c_like_utils.py @@ -1,7 +1,9 @@ """ -utilities fror C-like languages +utilities for C-like languages """ +import typing + from . import core from . import utils @@ -21,7 +23,10 @@ def escape_special_char(in_atom: core.Atom) -> str: return special_chars.get(in_atom.atom_char, in_atom.atom_char) -def get_atom_to_code(in_printer_function_name, in_escape_special_char_fun): +def get_atom_to_code( + in_printer_function_name: str, + in_escape_special_char_fun: typing.Callable[[core.Atom], str], +) -> typing.Callable[[core.Atom], str]: """returns the atom_to_code type function""" def _inner(in_atom: core.Atom) -> str: @@ -36,15 +41,19 @@ def get_function_call_str_fun(get_function_name): return utils.get_function_call_str_fun(get_function_name, "", "();") -def get_body_to_str(in_call_function_or_atom): +def get_body_to_str( + in_call_function_or_atom: typing.Callable[[core.CalledListEntry], str], +) -> typing.Callable[[core.SimpleFunction], str]: """returns body_to_str-like function for c-like languages""" return utils.get_body_to_str("\n", " ", in_call_function_or_atom, "", "") -def get_merge_to_full_function(in_function_prefix): +def get_merge_to_full_function( + in_function_prefix: str, +) -> typing.Callable[[str, str], str]: """returns merge_to_full_function-like function for c-like languages""" - def _merge_to_full_function(in_function_name, in_function_body): + def _merge_to_full_function(in_function_name: str, in_function_body: str) -> str: body_str = "\n" + in_function_body + "\n" if in_function_body else "" return "\n".join( [ @@ -59,7 +68,7 @@ def _merge_to_full_function(in_function_name, in_function_body): def get_main_call_fun(in_call_function_or_atom): """returns function returning code of main C or C++ function""" - def _main_call(in_initial_call, **kwargs): + def _main_call(in_initial_call: str | None, **kwargs) -> str: initial_call_str = ( " " + in_call_function_or_atom(in_initial_call, **kwargs) + "\n " if in_initial_call is not None diff --git a/string_to_code/utils.py b/string_to_code/utils.py index 7d11e08..24a6030 100644 --- a/string_to_code/utils.py +++ b/string_to_code/utils.py @@ -82,10 +82,10 @@ def get_all_proc_functions(main_call_to_code, function_to_code, join_to_final): def get_body_to_str( in_separator: str, in_prefix: str, - in_call_function_or_atom, + in_call_function_or_atom: typing.Callable[[core.CalledListEntry], str], in_postfix: str, in_empty_result: str, -): +) -> typing.Callable[[core.SimpleFunction], str]: """returns body_to_str-like function""" def _body_to_str(in_function: core.SimpleFunction) -> str: @@ -100,7 +100,9 @@ def _body_to_str(in_function: core.SimpleFunction) -> str: def get_function_to_code( - in_get_function_name, in_body_to_str, in_merge_to_full_function + in_get_function_name, + in_body_to_str: typing.Callable[[core.SimpleFunction], str], + in_merge_to_full_function: typing.Callable[[str, str], str], ): """return function_to_code-like function"""