Skip to content

refactor: use pathlib for the paths pymake builds - #336

Merged
jdhughes-dev merged 1 commit into
developfrom
pathlib-batch-3
Aug 18, 2026
Merged

refactor: use pathlib for the paths pymake builds#336
jdhughes-dev merged 1 commit into
developfrom
pathlib-batch-3

Conversation

@jdhughes-dev

Copy link
Copy Markdown
Collaborator

os.path is replaced by pathlib where a path is built or a file is removed in pymake.py, which is 15 of the 28 calls.

The rest are left because os.path does something pathlib does not, and each was checked rather than assumed:

os.path pathlib
normpath('a/../b') b a/../b, the parent directories are kept
splitext('bin/mf6.exe')[0] bin/mf6 .stem is mf6, the directory is dropped
dirname('mf6') empty .
abspath leaves a symbolic link .resolve() follows it

normpath tidies the extrafiles paths that are written to a build file, dirname is compared with appdir to decide where a target is written, and abspath decides whether a target has been built already, so converting any of them changes what pymake does.

Checked with the 67 base tests, by writing the mfusg makefile and comparing it, and by building triangle into an appdir, which is what the dirname comparison decides.

os.path is replaced by pathlib where a path is built or a file is removed in
pymake.py, which is 15 of the 28 calls.

The rest are left because os.path does something pathlib does not.
os.path.normpath takes the parent directories out of a path and pathlib does
not, and it is what tidies the extrafiles paths that are written to a build
file. os.path.splitext keeps the directory in the name it returns where
Path.stem does not. os.path.dirname returns an empty string for the directory
of a bare file name where Path.parent returns a dot, which is compared with
appdir to decide where a target is written. os.path.abspath does not resolve
a symbolic link where Path.resolve does, and it decides whether a target has
been built already.
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.170%. Comparing base (0c765d3) to head (c14bc0f).

Files with missing lines Patch % Lines
pymake/pymake.py 57.142% 6 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           develop      #336       +/-   ##
=============================================
- Coverage   80.231%   80.170%   -0.061%     
=============================================
  Files           20        20               
  Lines         3283      3283               
=============================================
- Hits          2634      2632        -2     
- Misses         649       651        +2     
Files with missing lines Coverage Δ
pymake/pymake.py 75.659% <57.142%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdhughes-dev
jdhughes-dev merged commit 0daee08 into develop Aug 18, 2026
23 checks passed
@jdhughes-dev
jdhughes-dev deleted the pathlib-batch-3 branch August 18, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant