Skip to content

Commit c28e270

Browse files
authored
Apply minimal fix for ruff rule PATH103 using Path.resolve (#14711)
* fix os.path.abspath * ensuring usage of path is str
1 parent a2f427e commit c28e270

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

dev-tools/scripts/buildAndPushRelease.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def pushLocal(version: str, root: str, rcNum: int, localDir: str):
238238
run("chmod -R a+rX-w .")
239239

240240
print(" done!")
241-
return "file://%s/%s" % (os.path.abspath(localDir), dir)
241+
return "file://%s/%s" % (Path(localDir).resolve(), dir)
242242

243243

244244
def read_version(_path: str):

dev-tools/scripts/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ ignore = [
9595
"PLW0602", # using global for variable but no assignment is done
9696
"PLW0603", # using global statement to update variable is discouraged
9797
"PLW2901", # loop variable overwritten by assignment target
98-
"PTH100", # os.path.abspath should be replaced by Path.resolve
9998
"PTH104", # os.rename should be replaced by Path.rename
10099
"PTH107", # os.remove shoudl be replaced by Path.unlink
101100
"PTH109", # os.getcwd should be replaced by Path.cwd

dev-tools/scripts/releaseWizard.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ def main():
12831283
if root.startswith("~/"):
12841284
release_root = os.path.expanduser(root)
12851285
else:
1286-
release_root = os.path.abspath(root)
1286+
release_root = str(Path(root).resolve())
12871287
if not os.path.exists(release_root):
12881288
try:
12891289
print("Creating release root %s" % release_root)
@@ -1306,7 +1306,7 @@ def main():
13061306
y = yaml.load(open(os.path.join(script_path, "releaseWizard.yaml")), Loader=yaml.Loader)
13071307
templates = y.get("templates")
13081308
todo_list = y.get("groups")
1309-
state = ReleaseState(release_root, release_version, getScriptVersion())
1309+
state = ReleaseState(str(release_root), release_version, getScriptVersion())
13101310
state.init_todos(bootstrap_todos(todo_list))
13111311
state.load()
13121312
except Exception as e:
@@ -1352,7 +1352,7 @@ def main():
13521352

13531353

13541354
sys.path.append(os.path.dirname(__file__))
1355-
current_git_root = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.path.pardir, os.path.pardir))
1355+
current_git_root: str = str(Path(os.path.join(Path(os.path.dirname(__file__)).resolve(), os.path.pardir, os.path.pardir)).resolve())
13561356

13571357
dry_run = False
13581358

dev-tools/scripts/scriptutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import urllib.request
2323
from collections.abc import Callable
2424
from enum import Enum
25+
from pathlib import Path
2526
from re import Match, Pattern
2627
from typing import Self, override
2728

@@ -188,7 +189,7 @@ def attemptDownload(urlString: str, fileName: str):
188189

189190
def find_current_version():
190191
script_path = os.path.dirname(os.path.realpath(__file__))
191-
top_level_dir = os.path.join(os.path.abspath("%s/" % script_path), os.path.pardir, os.path.pardir)
192+
top_level_dir = os.path.join(Path("%s/" % script_path).resolve(), os.path.pardir, os.path.pardir)
192193
match = version_prop_re.search(open("%s/build.gradle" % top_level_dir).read())
193194
assert match
194195
return match.group(2).strip()

dev-tools/scripts/smokeTestRelease.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def run(command: str, logFile: str):
447447
if cygwin:
448448
command = cygwinifyPaths(command)
449449
if os.system("%s > %s 2>&1" % (command, logFile)):
450-
logPath = os.path.abspath(logFile)
450+
logPath: str = str(Path(logFile).resolve())
451451
print('\ncommand "%s" failed:' % command)
452452
printFileContents(logFile)
453453
raise RuntimeError('command "%s" failed; see log file %s' % (command, logPath))
@@ -1023,7 +1023,7 @@ def parse_config():
10231023
c.java = make_java_config(parser, c.test_alternative_java)
10241024

10251025
if c.tmp_dir:
1026-
c.tmp_dir = os.path.abspath(c.tmp_dir)
1026+
c.tmp_dir = str(Path(c.tmp_dir).resolve())
10271027
else:
10281028
tmp = "/tmp/smoke_lucene_%s_%s" % (c.version, c.revision)
10291029
c.tmp_dir = tmp

0 commit comments

Comments
 (0)