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

Add some linting jobs for CI #1807

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Dec 4, 2024

This is currently a draft since it only affects python files ATM. I'd like to also lint JSON and meson files.

@@ -101,3 +102,4 @@ def main():

if __name__ == "__main__":
main()

Copy link
Member

Choose a reason for hiding this comment

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

Hmm?

Copy link
Member Author

Choose a reason for hiding this comment

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

what do you know, a file with a missing new line. The very thing that started this :)

Copy link
Member

@eli-schwartz eli-schwartz Dec 4, 2024

Choose a reason for hiding this comment

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

Normally github's view of this would have indicated via some kind of red circle when the previous version didn't have a trailing end of line character, I thought. Meanwhile, the actual display here is this adds a blank line 105 to go with the code line 104. Files ending with main() are a problem and files ending with main()\n are correct... but if I checkout your PR, the file ends with main()\n\n, which is surely wrong?

In fact, if I checkout the file in git master locally, it doesn't appear to be missing the trailing end of line character.

Comment on lines -9 to +10
for l in x.splitlines():
if b'examples' in l:
lines.append(str(l.replace(b'\\',b'/')))
for line in x.splitlines():
if b'examples' in line:
lines.append(str(line.replace(b'\\',b'/')))
Copy link
Member

Choose a reason for hiding this comment

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

This specific ruff "issue" is extremely opinionated and also wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

I get that it's opinionated, and in this case I'd agree waht was there before was fine, I think the second loop is more readaable with a line vs l though, since it's a long loop and things like line[len('MY_REALLY_LONG_STRING):] are generally more readable than l[len('MY_REALLY_LONG_STRING):]

Comment on lines -3 to +4
import os, sys
import os
import sys
Copy link
Member

Choose a reason for hiding this comment

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

Ugh, please can we not!

Copy link
Member Author

@dcbaker dcbaker Dec 4, 2024

Choose a reason for hiding this comment

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

Can we follow standard python coding guidelines? yes please

Copy link
Member

Choose a reason for hiding this comment

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

Nothing standard about this change, other than that black encourages it.

Copy link
Contributor

@trim21 trim21 Dec 5, 2024

Choose a reason for hiding this comment

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

This actually comes from pep8.

https://peps.python.org/pep-0008/#imports

(Even same modules, lol)

Copy link
Member

Choose a reason for hiding this comment

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

The authors and maintainers of the cpython PEPs take every possible opportunity they possibly can to tell people that PEP 8 is not a standard for anything other than "the style for internal cpython project source code" and that people should stop putting them in a position to be the arbiters of python style, funnily enough.

And this particular rule is inconsistent and ugly so I can kind of see the point. :)

@@ -121,7 +121,7 @@ def is_linux() -> bool:
return platform.system().lower() == 'linux'

def is_windows() -> bool:
return platform.system().lower() == 'windows' and not "MSYSTEM" in os.environ
return platform.system().lower() == 'windows' and "MSYSTEM" not in os.environ
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't tell is this is a bugfix.

@neheb
Copy link
Collaborator

neheb commented Dec 25, 2024

Please rebase

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.

4 participants