Skip to content

use jsonargparse#9413

Open
ThomasWaldmann wants to merge 16 commits intoborgbackup:masterfrom
ThomasWaldmann:jsonargparse2
Open

use jsonargparse#9413
ThomasWaldmann wants to merge 16 commits intoborgbackup:masterfrom
ThomasWaldmann:jsonargparse2

Conversation

@ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Feb 25, 2026

Description

Adopt jsonargparse, fixes #6551.

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

Previously, ArgparsePatternAction and ArgparsePatternFileAction
appended recursion roots directly to args.paths. This mixed
CLI positional paths with paths derived from patterns
(e.g., using the `R` root path command in a pattern file),
complicating downstream argument parsing and future jsonargparse
integration.

This commit introduces `args.pattern_roots` as a dedicated list
for these accumulated root paths:
- All argparse definition sites now initialize `pattern_roots=[]` alongside `paths=[]`
- ArgparsePatternAction and ArgparsePatternFileAction write directly to `args.pattern_roots`
- The build_matcher utility accepts both `include_paths` and `pattern_roots` and concatenates them internally
- `create_cmd` iterations explicitly concatenate both lists before processing

This ensures `args.paths` strictly reflects exactly what the
user provided positionally, paving the way for a clean
jsonargparse implementation without regressions in pattern behavior.
@ThomasWaldmann ThomasWaldmann force-pushed the jsonargparse2 branch 2 times, most recently from 89f6898 to 5aa0956 Compare February 25, 2026 14:08
@ThomasWaldmann ThomasWaldmann mentioned this pull request Feb 25, 2026
Guess it was triggered due to naming the variable "token",
maybe "sort_key" is less problematic.
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 88.57939% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.51%. Comparing base (23f7388) to head (5b9b450).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/helpers/parseformat.py 71.02% 21 Missing and 10 partials ⚠️
src/borg/patterns.py 66.66% 3 Missing ⚠️
src/borg/archiver/__init__.py 92.00% 1 Missing and 1 partial ⚠️
src/borg/archiver/diff_cmd.py 66.66% 2 Missing ⚠️
src/borg/archiver/transfer_cmd.py 66.66% 2 Missing ⚠️
src/borg/archiver/completion_cmd.py 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9413      +/-   ##
==========================================
+ Coverage   76.47%   76.51%   +0.03%     
==========================================
  Files          85       86       +1     
  Lines       14803    14913     +110     
  Branches     2213     2250      +37     
==========================================
+ Hits        11321    11411      +90     
- Misses       2803     2813      +10     
- Partials      679      689      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann ThomasWaldmann changed the title use jsonargparse, try 2 use jsonargparse Feb 26, 2026
@ThomasWaldmann ThomasWaldmann force-pushed the jsonargparse2 branch 2 times, most recently from 14adfd2 to c6452f7 Compare February 26, 2026 10:44
@ThomasWaldmann
Copy link
Member Author

@mauvilsa can you have a look, please?

maybe look at the individual commits.

is that flatten_namespace code in borg.helpers.argparsing interesting for other jsonargparse users?

had to import some internal stuff to implement borg completion command, guess there is currently no better way?

guess this can soon be merged - it does not use most features of jsonargparse, but that should be in future PRs.

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.

argparse++

1 participant