The Wayback Machine - https://web.archive.org/web/20211022001825/https://github.com/pytorch/pytorch/pull/55346
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

Enforce PEP263 for PyTorch python codebase #55346

Closed
wants to merge 10 commits into from

Conversation

@malfet
Copy link
Contributor

@malfet malfet commented Apr 6, 2021

All python files containing non-ASCII characters should be correctly annotated with # -*- coding: utf-8 -*- comment

Delete 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

malfet added 2 commits Apr 6, 2021
All python files containing non-ASCII characters should be correctly
annotated with `# -*- coding: utf-8 -*-` comment
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Apr 6, 2021

💊 CI failures summary and remediations

As of commit 763aa65 (more details on the Dr. CI page):


  • 2/2 failures introduced in this PR

2 failures not recognized by patterns:

Job Step Action
CircleCI pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_test2 Run tests 🔁 rerun
GitHub Actions clang-format Run clang-format 🔁 rerun

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 malfet changed the title Malfet/flake8 add pep263 check Enforce PEP263 for PyTorch python codebase Apr 6, 2021
@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Apr 6, 2021

@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@codecov
Copy link

@codecov codecov bot commented Apr 6, 2021

Codecov Report

Merging #55346 (56bd2eb) into master (d690973) will increase coverage by 0.00%.
The diff coverage is n/a.

Current head 56bd2eb differs from pull request most recent head bb36178. Consider uploading reports for the commit bb36178 to get more accurate results

@@           Coverage Diff           @@
##           master   #55346   +/-   ##
=======================================
  Coverage   77.47%   77.48%           
=======================================
  Files        1895     1895           
  Lines      187205   187205           
=======================================
+ Hits       145041   145049    +8     
+ Misses      42164    42156    -8     

Copy link
Contributor

@albanD albanD left a comment

Looks like flake8 expects to see this coding magic everywhere or it throws a warning (which we turn into an error)

@malfet
Copy link
Contributor Author

@malfet malfet commented Apr 6, 2021

@albanD , for the time being forked the plugin to make it optional for files that do not have utf-8

requirements-flake8.txt Outdated Show resolved Hide resolved
@malfet malfet requested review from BowenBao and neginraoof as code owners Apr 6, 2021
@malfet malfet requested a review from spandantiwari as a code owner Apr 6, 2021
@malfet
Copy link
Contributor Author

@malfet malfet commented Apr 6, 2021

@samestep I found a good example to add to trailing whitespace linter:

k = torch.randn(2, 3)  

It ends with number of non-breakable whitespaces U+00A0

@samestep
Copy link
Contributor

@samestep samestep commented Apr 6, 2021

@samestep I found a good example to add to trailing whitespace linter:

k = torch.randn(2, 3)  

It ends with number of non-breakable whitespaces U+00A0

Interesting! I'm very curious how those got there 🤔 I'll see if I can modify the regex to catch that sort of thing

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Apr 6, 2021

@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot facebook-github-bot commented Apr 7, 2021

@malfet merged this pull request in add49e7.

facebook-github-bot added a commit that referenced this issue Apr 8, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants