Skip to content

Commit 96dcd7c

Browse files
committed
Fix pep8 issues
1 parent 92bffc7 commit 96dcd7c

File tree

5 files changed

+81
-38
lines changed

5 files changed

+81
-38
lines changed

quark/cli.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
default=False,
149149
is_flag=True,
150150
help="Don't install Rizin automatically when no Rizin instance with"
151-
+ " a compatible version is found."
151+
+ " a compatible version is found.",
152152
)
153153
def entry_point(
154154
summary,
@@ -185,15 +185,22 @@ def entry_point(
185185

186186
if not rizin_path:
187187
print_error(
188-
"No valid Rizin executable found. Please specify the path to the Rizin executable by using option --rizin-path."
188+
"No valid Rizin executable found. Please specify the path"
189+
+ "to the Rizin executable by using option --rizin-path."
189190
)
190191
return
191192
else:
192193
version = get_rizin_version(rizin_path)
193194
if rizin_path.startswith(config.HOME_DIR):
194-
print_info(f"Use the Rizin executable (version {version}) installed in the Quark directory.")
195+
print_info(
196+
f"Use the Rizin executable (version {version})"
197+
+ " installed in the Quark directory."
198+
)
195199
else:
196-
print_info(f"Use the Rizin executable (version {version}) installed in the system PATH.")
200+
print_info(
201+
f"Use the Rizin executable (version {version})"
202+
+ " installed in the system PATH."
203+
)
197204

198205
else:
199206
print_info(f"Use the user-specified Rizin executable.")

quark/core/quark.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def __init__(self, apk, core_library="androguard", rizin_path=None):
4343
Create a Quark object.
4444
4545
:param apk: an APK for Quark to analyze
46-
:param core_library: a string indicating which analysis library Quark should use. Defaults to "androguard"
47-
:param rizin_path: a PathLike object to specify a Rizin executable for the Rizin-based analysis library. Defaults to None
46+
:param core_library: a string indicating which analysis library Quark
47+
should use. Defaults to "androguard"
48+
:param rizin_path: a PathLike object to specify a Rizin executable for
49+
the Rizin-based analysis library. Defaults to None
4850
:raises ValueError: if an unknown core library is specified
4951
"""
5052
core_library = core_library.lower()

quark/core/rzapkinfo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def __init__(
5959
if rizin_path:
6060
if not get_rizin_version(rizin_path):
6161
raise ValueError(
62-
f"The file in {rizin_path} is not a valid Rizin executable."
62+
f"The file in {rizin_path} is not a valid Rizin"
63+
+ " executable."
6364
)
6465

6566
rizin_path = os.path.dirname(rizin_path)

quark/utils/tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ def find_rizin_instance(
306306

307307
# The current version is not compatible
308308
print_info(
309-
"Find an outdated Rizin executable in the Quark directory. Try to update it."
309+
"Find an outdated Rizin executable in the Quark directory. Try to"
310+
+ " update it."
310311
)
311312

312313
if disable_rizin_installation:

tests/utils/test_tools.py

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77
import pytest
88
from quark import config
9-
from quark.utils.tools import (contains, descriptor_to_androguard_format,
10-
download_rizin, find_rizin_instance,
11-
get_rizin_version, remove_dup_list,
12-
update_rizin)
9+
from quark.utils.tools import (
10+
contains,
11+
descriptor_to_androguard_format,
12+
download_rizin,
13+
find_rizin_instance,
14+
get_rizin_version,
15+
remove_dup_list,
16+
update_rizin,
17+
)
1318

1419

1520
@pytest.fixture(scope="module")
@@ -189,7 +194,8 @@ def test_fail_to_download_rizin_due_to_unavailable_network(tmp_path):
189194
mock.side_effect = subprocess.CalledProcessError(
190195
"1",
191196
"mock command",
192-
stderr=b"fatal: unable to access 'https://github.com/rizinorg/rizin/'.",
197+
stderr=b"fatal: unable to access "
198+
+ "'https://github.com/rizinorg/rizin/'.",
193199
)
194200

195201
assert not download_rizin(target_path)
@@ -258,7 +264,8 @@ def test_find_rizin_instance_installed_in_quark_directory():
258264
with patch(
259265
"quark.utils.tools.get_rizin_version"
260266
) as mocked_get_version:
261-
# Pretent the Rizin instance installed in the Quark directory is compatible.
267+
# Pretent the Rizin instance installed in the Quark directory is
268+
# compatible.
262269
mocked_get_version.return_value = config.COMPATIBLE_RAZIN_VERSIONS[
263270
0
264271
]
@@ -269,8 +276,10 @@ def test_find_rizin_instance_installed_in_quark_directory():
269276
== rizin_executable_path
270277
)
271278

272-
mocked_which.assert_called() # Must check the system path first.
273-
mocked_get_version.assert_called() # Must check the version of the instance in the Quark directory.
279+
# Must check the system path first.
280+
mocked_which.assert_called()
281+
# Must check the version of the instance in the Quark directory.
282+
mocked_get_version.assert_called()
274283

275284

276285
def test_find_outdated_rizin_instance_installed_in_quark_directory(
@@ -287,7 +296,8 @@ def test_find_outdated_rizin_instance_installed_in_quark_directory(
287296
with patch(
288297
"quark.utils.tools.get_rizin_version"
289298
) as mocked_get_version:
290-
# Pretent the Rizin instance installed in the Quark directory is not compatible.
299+
# Pretent the Rizin instance installed in the Quark directory is
300+
# not compatible.
291301
mocked_get_version.return_value = "0.0.0"
292302

293303
with patch(
@@ -306,12 +316,17 @@ def test_find_outdated_rizin_instance_installed_in_quark_directory(
306316
== rizin_executable_path
307317
)
308318

309-
mocked_which.assert_called() # Must check the system path first.
310-
mocked_get_version.assert_called() # Must check the version of the instance in the Quark directory.
319+
# Must check the system path first.
320+
mocked_which.assert_called()
321+
# Must check the version of the instance in the Quark
322+
# directory.
323+
mocked_get_version.assert_called()
311324
if disable_rizin_installation:
312-
mocked_update_rizin.assert_not_called() # Must not update the instance
325+
# Must not update the instance
326+
mocked_update_rizin.assert_not_called()
313327
else:
314-
mocked_update_rizin.assert_called() # Must update the instance to a compatible version
328+
# Must update the instance to a compatible version
329+
mocked_update_rizin.assert_called()
315330

316331

317332
_compatible_trigger = None
@@ -367,20 +382,27 @@ def test_find_broken_rizin_instance_installed_in_quark_directory(
367382
)
368383
if disable_rizin_installation:
369384
# No Rizin instance exists
370-
assert result == None
385+
assert result is None
371386
else:
372387
# Must use the instance in the Quark directory.
373388
assert result == rizin_executable_path
374389

375-
mocked_which.assert_called() # Must check the system path first.
376-
mocked_get_version.assert_called() # Must check the version of the instance in the Quark directory.
390+
# Must check the system path first.
391+
mocked_which.assert_called()
392+
# Must check the version of the instance in the Quark
393+
# directory.
394+
mocked_get_version.assert_called()
377395

378396
if disable_rizin_installation:
379-
mocked_download_rizin.assert_not_called() # Must not download the source code.
380-
mocked_update_rizin.assert_not_called() # Must not update and compile a Rizin instance.
397+
# Must not download the source code.
398+
mocked_download_rizin.assert_not_called()
399+
# Must not update and compile a Rizin instance.
400+
mocked_update_rizin.assert_not_called()
381401
else:
382-
mocked_download_rizin.assert_called() # Must download the source code.
383-
mocked_update_rizin.assert_called() # Must update and compile a Rizin instance.
402+
# Must download the source code.
403+
mocked_download_rizin.assert_called()
404+
# Must update and compile a Rizin instance.
405+
mocked_update_rizin.assert_called()
384406

385407

386408
def test_find_rizin_instance_failed_to_download_the_source():
@@ -394,7 +416,8 @@ def test_find_rizin_instance_failed_to_download_the_source():
394416
with patch(
395417
"quark.utils.tools.get_rizin_version"
396418
) as mocked_get_version:
397-
# Pretent the Rizin instance installed in the Quark directory is broken.
419+
# Pretent the Rizin instance installed in the Quark directory is
420+
# broken.
398421
mocked_get_version.return_value = None
399422

400423
with patch(
@@ -406,12 +429,16 @@ def test_find_rizin_instance_failed_to_download_the_source():
406429
# Must use the instance in the Quark directory.
407430
assert (
408431
find_rizin_instance(rizin_source_path, target_commit)
409-
== None
432+
is None
410433
)
411434

412-
mocked_which.assert_called() # Must check the system path first.
413-
mocked_get_version.assert_called() # Must check the version of the instance in the Quark directory.
414-
mocked_download_rizin.assert_called() # Must try to download the source code of the Rizin.
435+
# Must check the system path first.
436+
mocked_which.assert_called()
437+
# Must check the version of the instance in the Quark
438+
# directory.
439+
mocked_get_version.assert_called()
440+
# Must try to download the source code of the Rizin.
441+
mocked_download_rizin.assert_called()
415442

416443

417444
def test_find_rizin_instance_failed_to_compile_or_update_the_source():
@@ -425,7 +452,8 @@ def test_find_rizin_instance_failed_to_compile_or_update_the_source():
425452
with patch(
426453
"quark.utils.tools.get_rizin_version"
427454
) as mocked_get_version:
428-
# Pretent the Rizin instance installed in the Quark directory is not compatible.
455+
# Pretent the Rizin instance installed in the Quark directory is
456+
# not compatible.
429457
mocked_get_version.return_value = "0.0.0"
430458

431459
with patch(
@@ -437,9 +465,13 @@ def test_find_rizin_instance_failed_to_compile_or_update_the_source():
437465
# Must use the instance in the Quark directory.
438466
assert (
439467
find_rizin_instance(rizin_source_path, target_commit)
440-
== None
468+
is None
441469
)
442470

443-
mocked_which.assert_called() # Must check the system path first.
444-
mocked_get_version.assert_called() # Must check the version of the instance in the Quark directory.
445-
mocked_update_rizin.assert_called() # Must try to update and compile a Rizin instance.
471+
# Must check the system path first.
472+
mocked_which.assert_called()
473+
# Must check the version of the instance in the Quark
474+
# directory.
475+
mocked_get_version.assert_called()
476+
# Must try to update and compile a Rizin instance.
477+
mocked_update_rizin.assert_called()

0 commit comments

Comments
 (0)