Skip to content

Commit 8441ffa

Browse files
committed
Removed warnings
- Do not import os.path as P, because of "Lowercase variable imported as non-lowercase" - Do not user `dir` as a name variable since it is a builtin function name. Avoids "Shadows built-in name 'dir'" - Avoid "Expected type 'None' (matched generic type '_VT'), got 'str' instead" when setting `res` by giving it the appropriate type hint.
1 parent 5c8a6a7 commit 8441ffa

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lkql_jit/standalone/make_native.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
"""
4242

4343
import os
44-
import os.path as P
44+
import os.path
4545
import subprocess
4646
import sys
4747

4848
sys.path.append("..")
49+
# noinspection PyUnresolvedReferences
4950
from utils import GraalManager, parse_args, is_windows
5051

5152

@@ -57,15 +58,15 @@ def look_for_files_in_env(files: list[str], env_var_name: str) -> dict[str, str]
5758
cannot be retrieved this function returns `None` and displays error message
5859
about file not being found.
5960
"""
60-
res = {f: None for f in files}
61-
for dir in os.environ.get(env_var_name, "").split(os.pathsep):
61+
res: dict[str, str | None] = {f: None for f in files}
62+
for directory in os.environ.get(env_var_name, "").split(os.pathsep):
6263
for file in files:
63-
if os.path.isfile(os.path.join(dir, file)):
64-
res[file] = dir
64+
if os.path.isfile(os.path.join(directory, file)):
65+
res[file] = directory
6566
break
6667
one_not_found = False
67-
for file, dir in res.items():
68-
if dir is None:
68+
for file, directory in res.items():
69+
if directory is None:
6970
one_not_found = True
7071
print(f'Cannot find "{file}" in {env_var_name}')
7172
return None if one_not_found else res
@@ -108,10 +109,13 @@ def look_for_files_in_env(files: list[str], env_var_name: str) -> dict[str, str]
108109
"--gc=G1",
109110
# Then we add additional options for the C compiler
110111
*[
111-
f"--native-compiler-options=-I{dir}"
112-
for dir in headers_paths.values()
112+
f"--native-compiler-options=-I{header_dir}"
113+
for header_dir in headers_paths.values()
114+
],
115+
*[
116+
f"--native-compiler-options=-L{lib_dir}"
117+
for lib_dir in libs_paths.values()
113118
],
114-
*[f"--native-compiler-options=-L{dir}" for dir in libs_paths.values()],
115119
*[f"--native-compiler-options={rp}" for rp in rpaths],
116120
]
117121
)
@@ -152,7 +156,7 @@ def look_for_files_in_env(files: list[str], env_var_name: str) -> dict[str, str]
152156
# Finally specify the main class name and the output file
153157
final_cmd = cmd + [
154158
"com.adacore.lkql_jit.cli.LKQLMain",
155-
P.join("target", "lkql"),
159+
os.path.join("target", "lkql"),
156160
]
157161

158162
# Debug print and run

0 commit comments

Comments
 (0)