InvalidArgument currently duplicates behavior that is already covered by the built-in exceptions TypeError and ValueError. In most cases across the codebase, the situations where InvalidArgument is raised are either:
- Incorrect types → should be
TypeError
- Incorrect values (but correct type) → should be
ValueError
Because Python already provides a clear semantic split here, InvalidArgument adds no meaningful benefit and instead introduces inconsistency in error patterns across the library.
Proposal
- Remove
InvalidArgument
- Replace existing uses with the appropriate built-in exception (
TypeError or ValueError depending on context)
- Update documentation and type hints accordingly
Benefits
- Aligns with standard Python exception semantics
- Improves clarity for users handling exceptions
- Reduces surface area of the public API
InvalidArgumentcurrently duplicates behavior that is already covered by the built-in exceptionsTypeErrorandValueError. In most cases across the codebase, the situations whereInvalidArgumentis raised are either:TypeErrorValueErrorBecause Python already provides a clear semantic split here,
InvalidArgumentadds no meaningful benefit and instead introduces inconsistency in error patterns across the library.Proposal
InvalidArgumentTypeErrororValueErrordepending on context)Benefits