-
Notifications
You must be signed in to change notification settings - Fork 209
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
|
||
with open(sys.argv[1], 'r') as f: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
import os | ||
import sys | ||
import re | ||
import subprocess | ||
|
||
# Put output files in the builddir | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os, sys | ||
import os | ||
import sys | ||
|
||
filename = sys.argv[1] | ||
linkname = sys.argv[2] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import sys | ||
import subprocess | ||
import os | ||
import tempfile | ||
|
||
# We want to print line endings normally, but each line should be a b'' string | ||
def clean(x): | ||
lines = [] | ||
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'/'))) | ||
Comment on lines
-9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This specific ruff "issue" is extremely opinionated and also wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
else: | ||
lines.append(str(l)) | ||
lines.append(str(line)) | ||
return '\n'.join(lines) | ||
|
||
def check_error(run_result, | ||
|
@@ -45,29 +44,28 @@ def check_error(run_result, | |
def main() -> int: | ||
m4_path = sys.argv[1] | ||
input_path = sys.argv[2] | ||
tmproot = sys.argv[3] | ||
workdir = sys.argv[4] | ||
workdir = sys.argv[3] | ||
examples_path = workdir + '/examples' | ||
if ':' in examples_path: | ||
examples_path = examples_path.partition(':')[2] | ||
with open(input_path, 'rb') as input_file, tempfile.TemporaryDirectory(dir=tmproot) as tmpdir: | ||
with open(input_path, 'rb') as input_file: | ||
expected_out = bytes() | ||
expected_err = bytes() | ||
ignore_err = False | ||
m4_input = bytes() | ||
for l in input_file.read().splitlines(): | ||
if l.startswith(b'dnl @ expected status: '): | ||
expected_code = int(l[len('dnl @ expected status: '):].rstrip()) | ||
if l.startswith(b'dnl @ extra options: '): | ||
args = l[len('dnl @ extra options: '):].rstrip().decode() | ||
if l.startswith(b'dnl @result{}'): | ||
expected_out += l[len('dnl @result{}'):] + os.linesep.encode() | ||
if l.startswith(b'dnl @error{}'): | ||
expected_err += l[len('dnl @error{}'):] + os.linesep.encode() | ||
if l.startswith(b'dnl @ expected error: ignore'): | ||
for line in input_file.read().splitlines(): | ||
if line.startswith(b'dnl @ expected status: '): | ||
expected_code = int(line[len('dnl @ expected status: '):].rstrip()) | ||
if line.startswith(b'dnl @ extra options: '): | ||
args = line[len('dnl @ extra options: '):].rstrip().decode() | ||
if line.startswith(b'dnl @result{}'): | ||
expected_out += line[len('dnl @result{}'):] + os.linesep.encode() | ||
if line.startswith(b'dnl @error{}'): | ||
expected_err += line[len('dnl @error{}'):] + os.linesep.encode() | ||
if line.startswith(b'dnl @ expected error: ignore'): | ||
ignore_err = True | ||
if not l.startswith(b'dnl @'): | ||
m4_input += l + b'\n' | ||
if not line.startswith(b'dnl @'): | ||
m4_input += line + b'\n' | ||
runargs = [] | ||
runargs.append(m4_path) | ||
runargs.append('-d') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import re | ||
from pathlib import Path | ||
|
||
def write_openblas_config_header(dest_dir, version, config_last_path, template_path): | ||
|
@@ -20,7 +21,7 @@ def write_openblas_config_header(dest_dir, version, config_last_path, template_p | |
rest_of_line = " ".join(parts[1:]) if len(parts) > 1 else "" | ||
line_to_write = f"#define OPENBLAS_{macro_name} {rest_of_line}" | ||
f.write(f"{line_to_write.strip()}\n") | ||
|
||
|
||
f.write(f'#define OPENBLAS_VERSION " OpenBLAS {version} "\n') | ||
|
||
|
@@ -101,3 +102,4 @@ def main(): | |
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 In fact, if I checkout the file in git |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import re | ||
import sys | ||
import pathlib | ||
import glob | ||
|
||
|
||
def verbose(*args): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os, pty, sys | ||
import os | ||
import pty | ||
import sys | ||
|
||
os.environ['TERM'] = 'xterm-256color' | ||
exit(os.waitstatus_to_exitcode(pty.spawn(sys.argv[1:]))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't tell is this is a bugfix. |
||
|
||
def is_msys() -> bool: | ||
return platform.system().lower() == 'windows' and "MSYSTEM" in os.environ | ||
|
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.
Ugh, please can we not!
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 we follow standard python coding guidelines? yes please
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.
Nothing standard about this change, other than that black encourages it.
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.
This actually comes from pep8.
https://peps.python.org/pep-0008/#imports
(Even same modules, lol)
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.
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. :)