Skip to content

Feature/exceptions#38

Merged
mosquito merged 5 commits intomasterfrom
feature/exceptions
Jan 24, 2026
Merged

Feature/exceptions#38
mosquito merged 5 commits intomasterfrom
feature/exceptions

Conversation

@mosquito
Copy link
Copy Markdown
Owner

@mosquito mosquito commented Jan 24, 2026

This pull request introduces a new structured exception hierarchy for the argclass library, refactors how exceptions are handled across the codebase, and improves the type safety and overload signatures for the argument factory functions. The changes enhance error reporting with richer context, unify exception handling, and clarify type annotations for argument definitions.

Exception handling and hierarchy

  • Added a new argclass/exceptions.py module defining a comprehensive exception hierarchy (ArgclassError, ArgumentDefinitionError, TypeConversionError, ConfigurationError, EnumValueError, ComplexTypeError) with rich context attributes and formatted error messages for better debugging and user feedback.
  • Updated imports in argclass/__init__.py, argclass/defaults.py, and argclass/factory.py to use the new exception classes, and replaced direct usage of built-in exceptions (e.g., ValueError) with the new structured types.

API and type annotation improvements

  • Refactored all overloads and function signatures for Argument, ArgumentSingle, and ArgumentSequence to use the new MetavarType for the metavar parameter, and clarified overloads for different combinations of type, nargs, and converter for improved type safety and IDE support.

Internal logic and backward compatibility

  • Updated the implementation of the argument factory logic to handle nargs="?" and other special cases more robustly, including correct dispatching to TypedArgument and ArgumentSequence, and ensured backward compatibility for exception attributes.

Public API exports

  • Updated the __all__ export list in argclass/__init__.py to include the new exception classes and the new MetavarType, making them available for users of the library.

These changes collectively improve error handling, type safety, and usability for developers using argclass.

@mosquito mosquito merged commit 04f06a0 into master Jan 24, 2026
11 checks passed
@mosquito mosquito deleted the feature/exceptions branch January 24, 2026 22:06
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