diff options
author | Patrik Teivonen <patrik.teivonen@qt.io> | 2022-09-16 12:34:27 +0300 |
---|---|---|
committer | Patrik Teivonen <patrik.teivonen@qt.io> | 2023-01-13 13:43:52 +0000 |
commit | 5687b7451e810a8bcc5d5fce69388b99a592ad0f (patch) | |
tree | 7e6811aa41d20844e116a317679de5f4354bb6cf | |
parent | 43fdb1ebe2bee68b7cda8930f1baa6f5a2b7d572 (diff) |
PL101: os.chmod("foo", perm) should be replaced by Path.chmod(perm)
Use pathlib to change file system permissions.
Enable PL101 in flake8
Change-Id: Ibaadea6d0768d89770ef0c05ca5f1c3ac9cb0133
Reviewed-by: Antti Kokko <antti.kokko@qt.io>
-rw-r--r-- | .pre-commit-config.yaml | 2 | ||||
-rw-r--r-- | packaging-tools/bldinstallercommon.py | 2 | ||||
-rw-r--r-- | packaging-tools/create_installer.py | 10 |
3 files changed, 7 insertions, 7 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d952f7839..ca7ee7703 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: # Disable E203 for compatibility with blackformatter, and W503 as it goes against PEP8 # Disable checks that are not relevant to this patch, they will be introduced later # - pathlib checks PLXXX - entry: pipenv run python3 -m flake8 --max-line-length=99 --ignore=E203,E501,W503,PL100,PL101,PL102,PL103,PL104,PL106,PL107,PL110,PL112,PL113,PL114,PL115,PL116,PL117,PL118,PL119,PL120,PL122,PL123 + entry: pipenv run python3 -m flake8 --max-line-length=99 --ignore=E203,E501,W503,PL100,PL102,PL103,PL104,PL106,PL107,PL110,PL112,PL113,PL114,PL115,PL116,PL117,PL118,PL119,PL120,PL122,PL123 language: system types: [python] fail_fast: true diff --git a/packaging-tools/bldinstallercommon.py b/packaging-tools/bldinstallercommon.py index 84896d9a0..84e644f72 100644 --- a/packaging-tools/bldinstallercommon.py +++ b/packaging-tools/bldinstallercommon.py @@ -244,7 +244,7 @@ def handle_remove_readonly( ) -> None: excvalue = exc[1] if func in (os.rmdir, os.remove) and excvalue == errno.EACCES: - os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 + Path(path).chmod(stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 func(path) else: raise PackagingError(excvalue) diff --git a/packaging-tools/create_installer.py b/packaging-tools/create_installer.py index 9644092c4..9aee960d4 100644 --- a/packaging-tools/create_installer.py +++ b/packaging-tools/create_installer.py @@ -659,11 +659,11 @@ def get_component_data( def handle_set_executable(base_dir: str, package_finalize_items: str) -> None: for item in parse_package_finalize_items(package_finalize_items, 'set_executable'): - expected_path = os.path.join(base_dir, item) - if not os.path.exists(expected_path): - raise CreateInstallerError(f'Can not set executable bit as path not found: "{expected_path}"') - os.chmod(expected_path, 0o755) - log.info("Executable bit set for: %s", expected_path) + exp_path = Path(base_dir, item) + if not os.path.exists(exp_path): + raise CreateInstallerError(f'Cannot set executable bit, path not found: "{exp_path}"') + exp_path.chmod(0o755) + log.info("Executable bit set for: %s", exp_path) def handle_set_licheck( |