Skip to content

Preserve tabs when creating XML reports (#5942) #5945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ def __init__(self, reports: Reports, output_dir: str) -> None:

# XML doesn't like control characters, but they are sometimes
# legal in source code (e.g. comments, string literals).
control_fixer = str.maketrans(''.join(chr(i) for i in range(32)), '?' * 32)
# Tabs (#x09) are allowed in XML content.
control_fixer = str.maketrans(''.join(chr(i) for i in range(32) if i != 9), '?' * 31)

def on_file(self,
tree: MypyFile,
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/reports.test
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def untyped_function():
# cmd: mypy --html-report report n.py
[file n.py]
class A(object):
pass # hex 1f here: ()
pass # line indented with tab; hex 1f here: ()

[file report/mypy-html.css]
[file report/index.html]
Expand All @@ -96,7 +96,7 @@ class A(object):
<span id="L2" class="lineno"><a class="lineno" href="#L2">2</a></span>
</pre></td>
<td class="table-code"><pre><span class="line-empty" title="No Anys on this line!">class A(object):</span>
<span class="line-empty" title="No Anys on this line!"> pass # hex 1f here: (?)</span>
<span class="line-empty" title="No Anys on this line!"> pass # line indented with tab; hex 1f here: (?)</span>
</pre></td>
</tr></tbody>
</table>
Expand Down