Skip to content

Fix list of paths files not relative to their location and nested sub_configs in add_argument - #1023

Merged
mauvilsa merged 2 commits into
mainfrom
fix-list-of-paths-relative-and-nested-sub-configs
Oct 22, 2026
Merged

mauvilsa merged 2 commits into
mainfrom
fix-list-of-paths-relative-and-nested-sub-configs

Conversation

@mauvilsa

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes plain text files with a list of paths, i.e. list[<path_type>] with sub_configs=True. When the file was not in the working directory, parsing failed with an unclear Expected type ... Got value error that showed the whole file content. A missing path in the list gave the same error. A file listing a single existing file was replaced by the lines of that file. Now relative paths in the list are resolved with respect to the location of the list file, consistent with relative paths inside config files.

Errors for an item of a list now say where it came from, in the same way as errors for values in config files. For a plain text list file, the error includes the line of the path, e.g. Source: list of paths file subdir/files.lst:2 followed by that line. For a list given as a yaml sub-config file, it includes the line of the item.

Optional[list[<path_type>]] now also accepts a file with a list of paths, both in add_argument and in signatures.

Also fixes add_argument with sub_configs=True and a class type, which did not accept sub-config files for the parameters of nested classes and failed with Unexpected import path format.

Before submitting

  • Did you read the contributing guideline?
  • If you used a coding agent, did you fully understand and validate all generated code and ensure it follows the contributing guidelines?
  • Did you update the documentation? (readme and public docstrings)
  • Did you write unit tests such that there is 100% coverage on related code? (required for bug fixes and new features)
  • Did you verify that new and existing tests pass locally?
  • If this is a bug fix, did you verify that the tests fail without the code fix?
  • Did you make sure that all changes preserve backward compatibility?
  • Did you update the CHANGELOG including a pull request link? (not for typos, docs, test updates, or minor internal changes/refactors)

@mauvilsa mauvilsa added bug Something isn't working enhancement New feature or request refactor Improvements to the quality of the code labels Oct 22, 2026
@mauvilsa
mauvilsa deployed to sonarcloud October 22, 2026 05:37 — with GitHub Actions Active
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (54186cc) to head (00589bd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1023   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         9926      9950   +24     
=========================================
+ Hits          9926      9950   +24     

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

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect path-list and nested-class configuration workflows in the library.

The PR appears safe to merge, with two non-blocking edge cases in optional path lists.

Findings

  1. P2 Listed file silently disappears ▶
  2. P2 Optional lists lose error locations ▶

Summary

This PR fixes relative paths in plain-text path lists and enables sub-config files for nested classes added with add_argument.

  • Path-list arguments resolve entries from their list file and point errors to the right line.
  • Nested class arguments can load their own config files.

Reviews (1) · Last reviewed commit: "Fix list of paths files not relative to ..." · Reviewed by Greptile

Comment thread jsonargparse/_typehints.py Outdated
Comment thread jsonargparse/_typehints.py Outdated
@mauvilsa
mauvilsa deployed to sonarcloud October 22, 2026 06:25 — with GitHub Actions Active
@sonarqubecloud

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit 7ef2bab into main Oct 22, 2026
35 checks passed
@mauvilsa
mauvilsa deleted the fix-list-of-paths-relative-and-nested-sub-configs branch October 22, 2026 06:32

This branch was successfully deployed

1 active deployment
sonarcloud — 00589bd5 Deployed Oct 22, 2026 by mauvilsa via sonarcloud #998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request refactor Improvements to the quality of the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant