Skip to content

Commit

Permalink
fix: Don't escape signatures return annotations
Browse files Browse the repository at this point in the history
Issue #6: #6
  • Loading branch information
pawamoy committed Feb 24, 2022
1 parent 4e895b0 commit ac54bfc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{%- endif -%}
{%- endfor -%}
)
{%- if config.show_signature_annotations and function.annotation %} -> {{ function.annotation }}{%- endif -%}
{%- if config.show_signature_annotations and function.annotation %} -> {{ function.annotation|safe }}{%- endif -%}

{%- endwith -%}
{%- endif -%}
12 changes: 12 additions & 0 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ def test_render_docstring_examples_section(renderer):
assert "<p>This is an example.</p>" in rendered
assert "print" in rendered
assert "Hello" in rendered


def test_format_code_and_signature(renderer):
"""Assert code and signatures can be Black-formatted.
Parameters:
renderer: A renderer instance (parametrized).
"""
assert renderer.do_format_code("print('Hello')", 100)
assert renderer.do_format_code('print("Hello")', 100)
assert renderer.do_format_signature("(param: str = 'hello') -> 'Class'", 100)
assert renderer.do_format_signature('(param: str = "hello") -> "Class"', 100)

0 comments on commit ac54bfc

Please sign in to comment.