Skip to content

Commit 6fa3840

Browse files
committed
various linter fixes
1 parent ab7f467 commit 6fa3840

9 files changed

Lines changed: 28 additions & 34 deletions

File tree

pbpy/pbengine.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import json
2-
32
from pathlib import Path
43

5-
from pbpy import pbconfig
6-
from pbpy import pbtools
7-
from pbpy import pblog
8-
from pbpy import pbgit
9-
from pbpy import pbuac
4+
from pbpy import pbgit, pbtools
105

116

127
def generate_module_changes(old_commitish, new_commitish):

pbpy/pbgit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def get_locked(key="ours", include_new=True):
157157
if proc.returncode:
158158
return None
159159
locked_objects = json.loads(proc.stdout)[key]
160-
locked = set([l.get("path") for l in locked_objects])
160+
locked = set([lock.get("path") for lock in locked_objects])
161161
# also check untracked and added files
162162
if key == "ours" and include_new:
163163
proc = pbtools.run_with_combined_output(

pbpy/pbsteamcmd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import os
22
import re
33
import shutil
4-
import time
54
import traceback
65
import urllib.request
76
from pathlib import Path
87

98
import gevent
10-
import steam.protobufs.steammessages_partnerapps_pb2 # don't remove
9+
import steam.protobufs.steammessages_partnerapps_pb2 # noqa: F401 - don't remove
1110
from steam.client import SteamClient
1211

1312
from pbpy import pbconfig, pbinfo, pblog, pbtools

pbpy/pbtools.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def compare_hash_single(compared_file_path, hash_json_file_path):
285285
dict_search_string = f"{compared_file_path}"
286286
hash_dict = get_dict_from_json(hash_json_file_path)
287287

288-
if hash_dict is None or not (dict_search_string in hash_dict):
288+
if hash_dict is None or dict_search_string not in hash_dict:
289289
pblog.error(f"Key {dict_search_string} not found in {hash_json_file_path}")
290290
return False
291291

@@ -720,8 +720,7 @@ def res_log(log):
720720
chunked_files = chunks(changed_files, batch_size)
721721

722722
# make index.lock to block LFS from updating index
723-
with open(".git/index.lock", "w") as f:
724-
pass
723+
Path(".git/index.lock").touch()
725724

726725
# Update index without FS monitor
727726
run(
@@ -862,7 +861,7 @@ def res_log(log):
862861
):
863862
if should_attempt_auto_resolve():
864863
pblog.error("Untracked files would be overwritten. Retrying...")
865-
files = [l.strip() for l in out.splitlines()[1:]]
864+
files = [line.strip() for line in out.splitlines()[1:]]
866865
run_with_combined_output(
867866
[pbgit.get_git_executable(), "add", "-A", "--", *files]
868867
)

pbpy/pbuac.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ def runAsAdmin(cmdLine=None, wait=True):
7070
if os.name != "nt":
7171
raise RuntimeError("This function is only implemented on Windows.")
7272

73-
import win32con, win32event, win32process, pywintypes
74-
from win32com.shell.shell import ShellExecuteEx
73+
import pywintypes
74+
import win32con
75+
import win32event
76+
import win32process
7577
from win32com.shell import shellcon
78+
from win32com.shell.shell import ShellExecuteEx
7679

7780
if not isinstance(cmdLine, (tuple, list)):
7881
raise ValueError("cmdLine is not a sequence.")

pbpy/pbunreal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ def download_engine(bundle_name: str, download_symbols: bool):
886886
# create install dir if doesn't exist
887887
os.makedirs(root, exist_ok=True)
888888

889-
root_path = Path(root)
890889
base_path = get_engine_base_path()
891890

892891
if not legacy_archives:
@@ -1558,8 +1557,8 @@ def inspect_source(all=False):
15581557
def clean_binaries_folder(clean_pdbs):
15591558
base_path = Path(".")
15601559
for binaries_path in binaries_paths:
1561-
for glob in clean_binaries_globs:
1562-
for file in base_path.glob(f"{binaries_path}/{get_platform_name()}/{glob}"):
1560+
for binary_glob in clean_binaries_globs:
1561+
for file in base_path.glob(f"{binaries_path}/{get_platform_name()}/{binary_glob}"):
15631562
file.unlink()
15641563

15651564
if clean_pdbs:

pbsync/__main__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import multiprocessing
44
import os
55
import sys
6+
from ast import literal_eval
67
from functools import partial
78
from pathlib import Path
8-
from ast import literal_eval
99

1010
from pbpy import (
1111
pbbutler,
@@ -285,7 +285,7 @@ def main(argv):
285285
)
286286
parser.add_argument(
287287
"--uproject",
288-
help=f"Multi-project folders only: project name to choose from. If not provided, it will prompt the user for one, or in CI environments, use the first one found.",
288+
help="Multi-project folders only: project name to choose from. If not provided, it will prompt the user for one, or in CI environments, use the first one found.",
289289
default="",
290290
)
291291

@@ -298,7 +298,7 @@ def main(argv):
298298
error_state(hush=True, term=True)
299299
return
300300

301-
if not (args.debugpath is None):
301+
if args.debugpath is not None:
302302
# Work on provided debug path
303303
os.chdir(str(args.debugpath))
304304

@@ -374,7 +374,7 @@ def pbsync_config_parser_func(root):
374374
# Attempt to parse literal as a python literal if its type does not match the type of the default value.
375375
# fixes bugs where config.get(key) is ran on a key which is expected to be boolean
376376
# if the key is set in config, its boolean implicit cast will always be true, since strings 'False' and 'True' both evaluate to True when converting to bool.
377-
if is_single and (default is not None) and type(el) != type(default):
377+
if is_single and (default is not None) and type(el) is not type(default):
378378
try:
379379
el = literal_eval(el) # not as crazy as eval, only parses literals (https://docs.python.org/3/library/ast.html#ast.literal_eval)
380380
except (TypeError, ValueError) as e:
@@ -486,17 +486,17 @@ def pbsync_config_parser_func(root):
486486
error_state(hush=True)
487487

488488
# Parse args
489-
if not (args.printversion is None):
489+
if args.printversion is not None:
490490
printversion_handler(args.printversion)
491-
if not (args.clean is None):
491+
if args.clean is not None:
492492
clean_handler(args.clean)
493-
if not (args.sync is None):
493+
if args.sync is not None:
494494
sync_handler(args.sync)
495-
if not (args.autoversion is None):
495+
if args.autoversion is not None:
496496
autoversion_handler(args.autoversion)
497-
if not (args.build is None):
497+
if args.build is not None:
498498
build_handler(args.build)
499-
if not (args.publish is None):
499+
if args.publish is not None:
500500
publish_handler(args.publish)
501501

502502
pbconfig.shutdown()

pbsync/actions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import sys
33
import threading
4-
from pathlib import Path
54

65
from pbpy import pbconfig, pbgh, pbgit, pblog, pbtools, pbunreal
76
from pbsync import prereqs
@@ -343,7 +342,7 @@ def launch_project():
343342

344343
if not launched_editor:
345344
pblog.warning(
346-
f"CliqueSync failed to find a valid file association to launch the editor, and will attempt to launch the editor directly as a workaround."
345+
"CliqueSync failed to find a valid file association to launch the editor, and will attempt to launch the editor directly as a workaround."
347346
)
348347
pbtools.run_non_blocking_ex([pbunreal.get_editor_path(), path])
349348
pblog.warning(

pbsync/prereqs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def install(self) -> bool:
325325
repo="microsoft/git",
326326
asset_pattern=PlatformSpecificValue(
327327
platform_values={
328-
"win32": f"Git-*-64-bit.exe",
328+
"win32": "Git-*-64-bit.exe",
329329
"darwin": "git-*-universal.pkg",
330330
},
331331
),
@@ -340,7 +340,7 @@ def install(self) -> bool:
340340
}
341341
)
342342

343-
ok = linstall() == True
343+
ok = linstall() is True
344344
if ok:
345345
if os.name == "nt":
346346
# Reconfigure GCM path
@@ -462,7 +462,7 @@ def install(self) -> bool:
462462
"linux": PosixPackageInstaller(["git-lfs"]).install,
463463
}
464464
)
465-
ok = linstall() == True
465+
ok = linstall() is True
466466
if ok:
467467
# Configure LFS hooks for the user
468468
current_drive = Path().resolve()
@@ -592,7 +592,7 @@ def install(self) -> bool:
592592
or detected == pbgit.missing_version
593593
or (isinstance(detected, str) and detected.startswith("diff"))
594594
)
595-
ok = linstall() == True if need_install else True
595+
ok = linstall() is True if need_install else True
596596

597597
# (Re)configure GCM and verify
598598
gcm_bin = pbgit.get_gcm_executable()

0 commit comments

Comments
 (0)