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 skipping of physical checks when file does not end in newline #961

Merged
merged 1 commit into from Sep 15, 2020
Merged

fix skipping of physical checks when file does not end in newline #961

merged 1 commit into from Sep 15, 2020

Conversation

asottile
Copy link
Member

Resolves #960

except (SyntaxError, tokenize.TokenError):
self.report_invalid_syntax()

def maybe_check_physical(self, token):
def maybe_check_physical(self, token, prev_physical):
Copy link
Member

Choose a reason for hiding this comment

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

We may need to replicate some of this logic to Flake8

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, I plan to work on that today!

Copy link
Member Author

Choose a reason for hiding this comment

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

here's the flake8 patch with essentially the same logic!

https://gitlab.com/pycqa/flake8/-/merge_requests/451

@jaraco
Copy link

jaraco commented Sep 12, 2020

Confirmed it works for the reported case (which is my actual use-case):

draft $ python -c "import pathlib; pathlib.Path('tabbed.py').write_text('def foo():\\n\\tpass')"
draft $ pip-run -q --use-pep517 git+https://github.com/asottile/pycodestyle@physical_checks_last_line -- -m pycodestyle tabbed.py
flake8 3.7.9 requires pycodestyle<2.6.0,>=2.5.0, but you'll have pycodestyle 2.6.0 which is incompatible.
tabbed.py:2:1: W191 indentation contains tabs
tabbed.py:2:6: W292 no newline at end of file

pycodestyle.py Show resolved Hide resolved
@sigmavirus24 sigmavirus24 merged commit a1b1f7c into PyCQA:master Sep 15, 2020
@asottile asottile deleted the physical_checks_last_line branch September 15, 2020 23:45
This was referenced Mar 14, 2021
This was referenced Mar 15, 2021
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.

W191: missed when file ends without a newline
4 participants