aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoel Challis2026-02-13 19:21:51 +0100
committerGitHub2026-02-13 19:21:51 +0100
commit63a3fc3591f755d1ef6b36269e61df16f4c32707 (patch)
treee4e67372c677327dfdb2854cf31feb355e9ff4a5 /lib
parent45ccd2e9351b979f8eb8fa359db732e5374b0d53 (diff)
Fix `qmk flash` handling of paths relative to qmk_firmware (#25993)
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/path.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py
index 1739689adf..3b8bafbd4e 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -177,5 +177,17 @@ class FileType(argparse.FileType):
"""normalize and check exists
otherwise magic strings like '-' for stdin resolve to bad paths
"""
+ # TODO: This should not return both Path and TextIOWrapper as consumers
+ # assume that they can call Path.as_posix without checking type
+
+ # Handle absolute paths and relative paths to CWD
norm = normpath(string)
- return norm if norm.exists() else super().__call__(string)
+ if norm.exists():
+ return norm
+
+ # Handle relative paths to QMK_HOME
+ relative = Path(string)
+ if relative.exists():
+ return relative
+
+ return super().__call__(string)