Skip to content
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

Fix last character cut in html-report if file does not end with newline #3466

Merged
merged 3 commits into from
May 26, 2017

Conversation

ilinum
Copy link
Collaborator

@ilinum ilinum commented May 26, 2017

If a file did not end with a newline, html-report would not output it.

I couldn't find any tests for html report. Maybe it's worth having some.

If a file did not end with a newline, html-report would not output it.
@gvanrossum
Copy link
Member

gvanrossum commented May 26, 2017

The canonical way to solve this kind of thing is probably s.rstrip('\n') [EDIT: strip -> rstrip]

mypy/report.py Outdated
etree.SubElement(root, 'line',
number=str(lineno),
precision=stats.precision_names[status],
content=line_text)
content=line_text.strip('\n'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, rstrip().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it should still be the same, since we know we are always processing one line. But rstrip() is probably better stylistically.

Originally, I was worried about removing legitimate newlines in the code. But they will be escaped and therefore won't be removed.

@gvanrossum gvanrossum merged commit 278a10a into python:master May 26, 2017
@ilinum ilinum deleted the html-report-newline branch May 26, 2017 19:18
carljm added a commit to carljm/mypy that referenced this pull request May 30, 2017
* master: (23 commits)
  Make return type of open() more precise (python#3477)
  Add test cases that delete a file during incremental checking (python#3461)
  Parse each format-string component separately (python#3390)
  Don't warn about returning Any if it is a proper subtype of the return type (python#3473)
  Add __setattr__ support (python#3451)
  Remove bundled lib-typing (python#3337)
  Move version of extensions to post-release (python#3348)
  Fix None slice bounds with strict-optional (python#3445)
  Allow NewType subclassing NewType. (python#3465)
  Add console scripts (python#3074)
  Fix 'variance' label.
  Change label for variance section to just 'variance' (python#3429)
  Better error message for invalid package names passed to mypy (python#3447)
  Fix last character cut in html-report if file does not end with newline (python#3466)
  Print pytest output as it happens (python#3463)
  Add mypy roadmap (python#3460)
  Add flag to avoid interpreting arguments with a default of None as Optional (python#3248)
  Add type checking plugin support for functions (python#3299)
  Mismatch of inferred type and return type note (python#3428)
  Sync typeshed (python#3449)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants