Enforce PEP263 for PyTorch python codebase #55346
Conversation
All python files containing non-ASCII characters should be correctly annotated with `# -*- coding: utf-8 -*-` comment
|
Job | Step | Action |
---|---|---|
Run tests | ||
Run clang-format |
This comment was automatically generated by Dr. CI (expand for details).
Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group.
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Codecov Report
@@ Coverage Diff @@
## master #55346 +/- ##
=======================================
Coverage 77.47% 77.48%
=======================================
Files 1895 1895
Lines 187205 187205
=======================================
+ Hits 145041 145049 +8
+ Misses 42164 42156 -8 |
Looks like flake8 expects to see this coding magic everywhere or it throws a warning (which we turn into an error)
@albanD , for the time being forked the plugin to make it optional for files that do not have utf-8 |
@samestep I found a good example to add to trailing whitespace linter: pytorch/torch/onnx/__init__.py Line 85 in da7a27b It ends with number of non-breakable whitespaces U+00A0 |
Interesting! I'm very curious how those got there |
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: malfet found a couple of these in #55346; this PR removes the rest and adds a lint that prevents them from being accidentally added again in the future. It also removes the `-o` flag added in #53733 (which was unnecessarily hiding context without reducing the number of lines of output), and updates the lint error messages to reflect that the individual line numbers are shown in the logs. Pull Request resolved: #55465 Test Plan: The "Lint / quick-checks" job in GitHub Actions should succeed on this PR. To verify that the lint does correctly find and error on non-breaking spaces, checkout ece0751 and run it locally: ```sh (! git --no-pager grep -In $'\u00a0' -- . || (echo "The above lines have non-breaking spaces (U+00A0); please convert them to spaces (U+0020)"; false)) ``` It should print over a hundred lines of output and exit with status 1. Reviewed By: janeyx99 Differential Revision: D27622136 Pulled By: samestep fbshipit-source-id: e7ffd5a9519093e7a0ffdf55e9291f63e21ce841
All python files containing non-ASCII characters should be correctly annotated with
# -*- coding: utf-8 -*-
commentDelete number of superfluous UTF-8 characters, most commonly UTF-8 opening closing quotation mark U+2019 (’) instead of ascii apostrophe ', for example
Module’s
->Module's
The text was updated successfully, but these errors were encountered: