Skip to content

Support functions for callable protocols and typing aliases, plus a talks and articles page - #963

Merged
mauvilsa merged 5 commits into
mainfrom
improvements
Aug 25, 2026
Merged

Support functions for callable protocols and typing aliases, plus a talks and articles page#963
mauvilsa merged 5 commits into
mainfrom
improvements

Conversation

@mauvilsa

Copy link
Copy Markdown
Owner

What does this PR do?

Improvements to protocol and Callable type support, fixes for unsubscripted typing aliases, and documentation restructuring.

Added

  • A protocol whose single method is __call__ is now also implemented by a function with a compatible signature, so the import path of a function is accepted as value. The value is then the function itself, instead of a class to instantiate. --*.help for such a value gives a clear error, since a function has no class to describe.

Fixes #616

Fixed

  • Functions without a return annotation at runtime, e.g. C-implemented ones like time.localtime, were rejected for Callable types with a class return type. Now the return type from a .pyi is used when the stubs resolver is enabled.
  • Unsubscripted typing sequence aliases (List, Sequence, MutableSequence, Iterable, Collection, Container, Reversible and Deque) raised AttributeError: __args__, which made classes that have one in their signature, e.g. torch.utils.data.DataLoader, impossible to add.
  • typing.Hashable and typing.Sized were not supported, while the collections.abc spelling of the same types was. A bare one didn't validate and a composed one, e.g. Optional[Hashable], raised Unsupported type hint.

Documentation

  • New orphan page talks-and-articles collecting presentations, videos, blog posts and example projects, replacing the shorter Tutorials section in DOCUMENTATION.rst. Linked from the README and from CONTRIBUTING.rst.
  • The Comparison to Fire section moved into the auto_cli docstring, where it is more discoverable.
  • CONTRIBUTING.rst rephrased for conciseness.
  • Documented the new function-implements-protocol behavior and the return type requirement for functions given to Callable types.

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 labels Aug 25, 2026
Comment thread jsonargparse_tests/test_subclasses.py Dismissed
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (72c4885) to head (0baffc5).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #963   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           28        28           
  Lines         9162      9209   +47     
=========================================
+ Hits          9162      9209   +47     

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

@sonarqubecloud

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit d950f3f into main Aug 25, 2026
32 checks passed
@mauvilsa
mauvilsa deleted the improvements branch August 25, 2026 05:43
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Functions should implement callable protocols

2 participants