BREAKING: Raise GMTTypeError exception for invalid types. Previously raise GMTInvalidInput#3999
BREAKING: Raise GMTTypeError exception for invalid types. Previously raise GMTInvalidInput#3999
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the handling of invalid-type inputs by introducing and raising a new exception class GMTTypeError instead of GMTInvalidInput. Tests across many modules have been updated to expect GMTTypeError, and source files for core commands have been modified to import and raise the new exception. Additionally, the GMTTypeError class has been added to pygmt/exceptions.py.
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pygmt/exceptions.py | Added GMTTypeError subclass of TypeError for invalid input types |
| pygmt/src/x2sys_cross.py | Switched invalid-type error from GMTInvalidInput to GMTTypeError |
| pygmt/src/text.py | Updated array‐argument checks to raise GMTTypeError |
| pygmt/src/plot3d.py | Changed invalid‐array errors to raise GMTTypeError |
| pygmt/src/plot.py | Changed invalid‐array errors to raise GMTTypeError |
| pygmt/src/legend.py | Changed invalid‐type checks to raise GMTTypeError |
| pygmt/src/grdcut.py | Switched unsupported‐type error to GMTTypeError |
| pygmt/clib/session.py | Replaced several GMTInvalidInput raises with GMTTypeError, and updated docstrings |
| pygmt/tests/* | Updated tests to import and expect GMTTypeError instead of GMTInvalidInput |
|
Ping @GenericMappingTools/pygmt-maintainers for final reivews. I plan to merge in 48 hours. |
yvonnefroehlich
left a comment
There was a problem hiding this comment.
I am fine with the changes, just a few minor suggestions and comments.
pygmt/src/text.py
Outdated
| raise GMTInvalidInput(msg) | ||
| raise GMTTypeError( | ||
| type(arg), | ||
| reason=f"Parameter {name!r} expects a scalar value or True.", |
There was a problem hiding this comment.
With "scalar value", we refer to a float, or?
There was a problem hiding this comment.
I've changed it back to "single".
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
|
/format |
Following PR #3985. Addressing #3707 and #3984.
This PR adds a new exception
GMTTypeError. The error message is like: