-
Notifications
You must be signed in to change notification settings - Fork 193
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
Lint - merge markers - ignore binary files. #1040
Conversation
Also add ability to ignore specific files in config. Moved binary detection function into utils.
Codecov Report
@@ Coverage Diff @@
## dev #1040 +/- ##
==========================================
+ Coverage 69.54% 69.59% +0.04%
==========================================
Files 35 35
Lines 4344 4354 +10
==========================================
+ Hits 3021 3030 +9
- Misses 1323 1324 +1
Continue to review full report at Codecov.
|
try: | ||
with io.open(os.path.join(root, fname), "rt", encoding="latin1") as fh: | ||
for l in fh: | ||
if ">>>>>>>" in l: | ||
failed.append(f"Merge marker '>>>>>>>' in `{os.path.join(root, fname)}`: {l}") | ||
failed.append(f"Merge marker '>>>>>>>' in `{os.path.join(root, fname)}`: {l[:30]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a line be shorter than 30, and wold it break then? 🤔
Small idea although not really necessary, since we're looping through all the lines anyway we could also count them and spit out the line number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't break if it's shorter than 30, at least I'm pretty sure it doesn't. Let me check..
❯ python
Python 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 23:22:12)
[Clang 11.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> myvar = "123"
>>> myvar
'123'
>>> myvar[:30]
'123'
Yeah it's fine.
Could do line numbers I guess - but meh 🙄 Feel free to add if you want 😅
The reason I changed this is because I had a case where the entire several-MB file was on a single line with no newlines, and the whole thing was dumped into the lint error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright thanks for checking :)
Haha okay yeah I see that can be potentially annoying 😅
Merge markers lint test:
Moved binary detection function into utils.
PR checklist
CHANGELOG.md
is updateddocs
is updated