Skip to content

Commit fabc78c

Browse files
authored
fix: python lint more ruff rules (#291)
1 parent a2d7439 commit fabc78c

40 files changed

+258
-276
lines changed

gyp_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# found in the LICENSE file.
66

77
import os
8-
import sys
98
import subprocess
9+
import sys
1010

1111

1212
def IsCygwin():

pylib/gyp/MSVSProject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"""Visual Studio project reader/writer."""
66

7-
import gyp.easy_xml as easy_xml
7+
from gyp import easy_xml
88

99
# ------------------------------------------------------------------------------
1010

pylib/gyp/MSVSSettings_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"""Unit tests for the MSVSSettings.py file."""
88

99
import unittest
10-
import gyp.MSVSSettings as MSVSSettings
11-
1210
from io import StringIO
1311

12+
from gyp import MSVSSettings
13+
1414

1515
class TestSequenceFunctions(unittest.TestCase):
1616
def setUp(self):

pylib/gyp/MSVSToolFile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"""Visual Studio project reader/writer."""
66

7-
import gyp.easy_xml as easy_xml
7+
from gyp import easy_xml
88

99

1010
class Writer:

pylib/gyp/MSVSUserFile.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import re
99
import socket # for gethostname
1010

11-
import gyp.easy_xml as easy_xml
12-
11+
from gyp import easy_xml
1312

1413
# ------------------------------------------------------------------------------
1514

pylib/gyp/MSVSUtil.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import copy
88
import os
99

10-
1110
# A dictionary mapping supported target types to extensions.
1211
TARGET_TYPE_EXT = {
1312
"executable": "exe",

pylib/gyp/MSVSVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"""Handle version information related to Visual Stuio."""
66

77
import errno
8+
import glob
89
import os
910
import re
1011
import subprocess
1112
import sys
12-
import glob
1313

1414

1515
def JoinPath(*args):

pylib/gyp/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
# found in the LICENSE file.
66

77
from __future__ import annotations
8-
import copy
9-
import gyp.input
8+
109
import argparse
10+
import copy
1111
import os.path
1212
import re
1313
import shlex
1414
import sys
1515
import traceback
16-
from gyp.common import GypError
1716

17+
import gyp.input
18+
from gyp.common import GypError
1819

1920
# Default debug modes for GYP
2021
debug = {}
@@ -360,7 +361,7 @@ def gyp_main(args):
360361
action="store",
361362
env_name="GYP_CONFIG_DIR",
362363
default=None,
363-
help="The location for configuration files like " "include.gypi.",
364+
help="The location for configuration files like include.gypi.",
364365
)
365366
parser.add_argument(
366367
"-d",
@@ -529,14 +530,13 @@ def gyp_main(args):
529530
generate_formats = re.split(r"[\s,]", generate_formats)
530531
if generate_formats:
531532
options.formats = generate_formats
533+
# Nothing in the variable, default based on platform.
534+
elif sys.platform == "darwin":
535+
options.formats = ["xcode"]
536+
elif sys.platform in ("win32", "cygwin"):
537+
options.formats = ["msvs"]
532538
else:
533-
# Nothing in the variable, default based on platform.
534-
if sys.platform == "darwin":
535-
options.formats = ["xcode"]
536-
elif sys.platform in ("win32", "cygwin"):
537-
options.formats = ["msvs"]
538-
else:
539-
options.formats = ["make"]
539+
options.formats = ["make"]
540540

541541
if not options.generator_output and options.use_environment:
542542
g_o = os.environ.get("GYP_GENERATOR_OUTPUT")

pylib/gyp/common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import filecmp
77
import os.path
88
import re
9-
import tempfile
10-
import sys
11-
import subprocess
129
import shlex
13-
10+
import subprocess
11+
import sys
12+
import tempfile
1413
from collections.abc import MutableSet
1514

1615

@@ -35,7 +34,6 @@ class GypError(Exception):
3534
to the user. The main entry point will catch and display this.
3635
"""
3736

38-
pass
3937

4038

4139
def ExceptionAppend(e, msg):

pylib/gyp/common_test.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
"""Unit tests for the common.py file."""
88

9-
import gyp.common
10-
import unittest
11-
import sys
129
import os
13-
from unittest.mock import patch, MagicMock
10+
import sys
11+
import unittest
12+
from unittest.mock import MagicMock, patch
13+
14+
import gyp.common
15+
1416

1517
class TestTopologicallySorted(unittest.TestCase):
1618
def test_Valid(self):
@@ -109,30 +111,30 @@ def mock_run(env, defines_stdout, expected_cmd):
109111
return [defines, flavor]
110112

111113
[defines1, _] = mock_run({}, "", [])
112-
assert {} == defines1
114+
assert defines1 == {}
113115

114116
[defines2, flavor2] = mock_run(
115117
{ "CC_target": "/opt/wasi-sdk/bin/clang" },
116118
"#define __wasm__ 1\n#define __wasi__ 1\n",
117119
["/opt/wasi-sdk/bin/clang"]
118120
)
119-
assert { "__wasm__": "1", "__wasi__": "1" } == defines2
121+
assert defines2 == { "__wasm__": "1", "__wasi__": "1" }
120122
assert flavor2 == "wasi"
121123

122124
[defines3, flavor3] = mock_run(
123125
{ "CC_target": "/opt/wasi-sdk/bin/clang --target=wasm32" },
124126
"#define __wasm__ 1\n",
125127
["/opt/wasi-sdk/bin/clang", "--target=wasm32"]
126128
)
127-
assert { "__wasm__": "1" } == defines3
129+
assert defines3 == { "__wasm__": "1" }
128130
assert flavor3 == "wasm"
129131

130132
[defines4, flavor4] = mock_run(
131133
{ "CC_target": "/emsdk/upstream/emscripten/emcc" },
132134
"#define __EMSCRIPTEN__ 1\n",
133135
["/emsdk/upstream/emscripten/emcc"]
134136
)
135-
assert { "__EMSCRIPTEN__": "1" } == defines4
137+
assert defines4 == { "__EMSCRIPTEN__": "1" }
136138
assert flavor4 == "emscripten"
137139

138140
# Test path which include white space
@@ -149,11 +151,11 @@ def mock_run(env, defines_stdout, expected_cmd):
149151
"-pthread"
150152
]
151153
)
152-
assert {
154+
assert defines5 == {
153155
"__wasm__": "1",
154156
"__wasi__": "1",
155157
"_REENTRANT": "1"
156-
} == defines5
158+
}
157159
assert flavor5 == "wasi"
158160

159161
original_sep = os.sep
@@ -164,7 +166,7 @@ def mock_run(env, defines_stdout, expected_cmd):
164166
["C:/Program Files/wasi-sdk/clang.exe"]
165167
)
166168
os.sep = original_sep
167-
assert { "__wasm__": "1", "__wasi__": "1" } == defines6
169+
assert defines6 == { "__wasm__": "1", "__wasi__": "1" }
168170
assert flavor6 == "wasi"
169171

170172
if __name__ == "__main__":

0 commit comments

Comments
 (0)