Skip to content

Commit e03fff9

Browse files
committed
Resolved all violations reported by Flake8
1 parent b778328 commit e03fff9

File tree

11 files changed

+36
-31
lines changed

11 files changed

+36
-31
lines changed

lkql_checker/doc/share/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from os import path as P
88
import sys
9+
from sphinx.highlighting import lexers
910
import time
1011

1112
# Add own dir path
@@ -22,14 +23,12 @@
2223

2324
sys.path.append(lkql_user_manual_path)
2425

25-
import ada_pygments
26-
import latex_elements
27-
import lkql_lexer
26+
import ada_pygments # noqa: E402
27+
import latex_elements # noqa: E402
28+
import lkql_lexer # noqa: E402
2829

2930
# -- General configuration ---------------------------------------------------
3031

31-
from sphinx.highlighting import lexers
32-
3332
lexers["lkql"] = lkql_lexer.LKQLPygmentsLexer()
3433
lexers["ada"] = ada_pygments.AdaLexer()
3534
lexers["gpr"] = ada_pygments.GNATProjectLexer()

lkql_jit/standalone/make_native.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
import os
2+
import subprocess
3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.append("..")
7+
from utils import GraalManager, parse_args, is_windows # noqa E402
8+
19
"""----------------------------------------------------------------------------
210
-- L K Q L J I T --
311
-- --
@@ -40,16 +48,6 @@
4048
specified at any other place.
4149
"""
4250

43-
import os
44-
import subprocess
45-
import sys
46-
47-
from pathlib import Path
48-
49-
sys.path.append("..")
50-
# noinspection PyUnresolvedReferences
51-
from utils import GraalManager, parse_args, is_windows
52-
5351

5452
def look_for_files_in_env(files: list[str], env_var_name: str) -> dict[str, str] | None:
5553
"""

obj/debug/main-gdb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
dir_path = os.path.dirname(os.path.realpath(__file__))
55
printers_path = os.path.join(dir_path, "..", "..")
66

7-
87
sys.path.append(printers_path)
98

10-
import printers
9+
import printers # noqa: E402,F401

testsuite/drivers/base_driver.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ def errors(self) -> list[tuple[int, str]]:
100100
res.append(
101101
(
102102
line,
103-
f"unexpected flag count (expecting {flag_count}, actual {count})",
103+
(
104+
f"unexpected flag count (expecting {flag_count}, actual "
105+
f"{count})"
106+
),
104107
)
105108
)
106109

@@ -132,7 +135,8 @@ def add_missing_flags(self):
132135
# source.
133136
if len(self.matching_sources) > 1:
134137
raise TestAbortWithError(
135-
f"Cannot automatically add flags annotations in {self.file_name}, multiple sources are matching this name"
138+
f"Cannot automatically add flags annotations in {self.file_name}, "
139+
"multiple sources are matching this name"
136140
)
137141
source = self.matching_sources[0]
138142

@@ -503,7 +507,7 @@ def read_ada_file(cls, file_name: str) -> tuple[list[str], str]:
503507
lines = ada_bytes.decode(encoding).split("\n")
504508
lines = lines[:-1] if not lines[-1] else lines
505509
return (lines, encoding)
506-
except ValueError as _:
510+
except ValueError:
507511
pass
508512

509513
def _define_lkql_executables(self) -> None:

testsuite/drivers/benchmarks_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run(self):
2828
os.path.join(self.lkql_jit_dir, "benchmarks"),
2929
"jmh:benchmark",
3030
"-Djmh.rf=json",
31-
f"-Djmh.v=SILENT",
31+
"-Djmh.v=SILENT",
3232
f"-Djmh.rff={benchmark_results_json}",
3333
]
3434
self.shell(

testsuite/drivers/checker_driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def run(self) -> None:
8383
if auto_fix_mode in ["NEW_FILE", "PATCH_FILE"]:
8484
# Get the list of patched files by parsing the output
8585
patched_files = []
86-
for l in str(self.output).splitlines():
87-
search_result = patched_file_pattern.search(l)
86+
for line in str(self.output).splitlines():
87+
search_result = patched_file_pattern.search(line)
8888
if search_result is not None:
8989
groups = search_result.groups()
9090
patched_files.append(groups[2] or groups[0])

testsuite/drivers/gnatcheck_driver.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class GnatcheckDriver(BaseDriver):
137137
output_formats = set(["brief", "full", "short", "xml"])
138138

139139
flag_line_pattern = re.compile(
140-
rf"^({BaseDriver.ada_file_pattern}):(\d+):\d+: (rule violation|warning|error): .*$"
140+
rf"^({BaseDriver.ada_file_pattern}):(\d+):\d+: (rule violation|warning|error)"
141+
": .*$"
141142
)
142143

143144
@classmethod
@@ -415,7 +416,7 @@ def run_one_test(test_data: dict[str, any]) -> None:
415416
exe = GnatcheckDriver.modes[test_data.get("mode", "gnatcheck")]
416417
args = [exe, "-q"]
417418
output_file_name = test_data.get("output_file")
418-
if output_file_name is None or output_file_name == True:
419+
if output_file_name is None or output_file_name is True:
419420
output_file_name = self.working_dir(
420421
f"{exe}.{'xml' if output_format == 'xml' else 'out'}"
421422
)
@@ -635,12 +636,13 @@ def run_one_test(test_data: dict[str, any]) -> None:
635636
# include in the test baseline.
636637
report_file_content = "".join(f.readlines()[9:])
637638
has_output_file = True
638-
except FileNotFoundError as _:
639+
except FileNotFoundError:
639640
self.output += (
640641
"testsuite_driver: No output file generated by gnatcheck\n"
641642
)
642643

643-
# Get the lines flagged by the test running and add it to all flagged lines
644+
# Get the lines flagged by the test running and add it to all flagged
645+
# lines.
644646
if self.flag_checking and (has_output_file or output_format == "brief"):
645647
add_to_files_flagged_lines(
646648
self.parse_flagged_lines(

testsuite/drivers/interpreter_driver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def compute_failures(self):
6666
None,
6767
baseline,
6868
self.lkt_output,
69-
failure_message="execution after refactor TO_LKQL_V2: unexpected output",
69+
failure_message=(
70+
"execution after refactor TO_LKQL_V2: unexpected output"
71+
),
7072
)
7173

7274
case False:

user_manual/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
dir_path = os.path.dirname(os.path.realpath(__file__))
2525
sys.path.append(dir_path)
2626

27-
import lkql_lexer
27+
import lkql_lexer # noqa: E402
2828

2929
project = "LKQL"
3030
copyright = "2020, AdaCore"

user_manual/source/lkql_doc_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
LKQL_CLASSES = [
1717
v
1818
for _, v in liblkqllang.__dict__.items()
19-
if (type(v) == type and issubclass(v, liblkqllang.LkqlNode))
19+
if (type(v) is type and issubclass(v, liblkqllang.LkqlNode))
2020
]
2121

2222
except ImportError:

0 commit comments

Comments
 (0)