Conversation
94dd534 to
1c08162
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new structured exception hierarchy for the
argclasslibrary, 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
argclass/exceptions.pymodule 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.argclass/__init__.py,argclass/defaults.py, andargclass/factory.pyto 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
Argument,ArgumentSingle, andArgumentSequenceto use the newMetavarTypefor themetavarparameter, and clarified overloads for different combinations oftype,nargs, andconverterfor improved type safety and IDE support.Internal logic and backward compatibility
nargs="?"and other special cases more robustly, including correct dispatching toTypedArgumentandArgumentSequence, and ensured backward compatibility for exception attributes.Public API exports
__all__export list inargclass/__init__.pyto include the new exception classes and the newMetavarType, making them available for users of the library.These changes collectively improve error handling, type safety, and usability for developers using
argclass.