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.
|
| 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.
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.
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.
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.mdis updateddocsis updated