Skip to content

Add new exception GMTParameterError for invalid parameters #4003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

seisman
Copy link
Member

@seisman seisman commented Jul 21, 2025

No description provided.

@seisman seisman force-pushed the exception/parametererror branch 5 times, most recently from cc89cb1 to a4082e0 Compare July 21, 2025 08:11
Base automatically changed from exception/typeerror to main July 21, 2025 11:52
@seisman seisman force-pushed the exception/parametererror branch from cf33edc to e51bb31 Compare July 21, 2025 11:55
Comment on lines +160 to +164
if required:
msg = (
"Required parameter(s) are missing: "
f"{', '.join(repr(par) for par in required)}."
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case where the parameter(s) is required/compulsory, I'm wondering if we can move towards having the error being thrown natively by Python, instead of writing code like:

if kwargs.get("F") is None:
    raise GMTParameterError(required={"filter_type"})

Should we revisit #2896 which mentions PEP692, and also think about using PEP655's typing.Required qualifier (https://typing.python.org/en/latest/spec/callables.html#required-and-non-required-keys)? Maybe a step towards #262 is to disallow single character arguments for required parameters, so that we can have native Python errors?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main issue is that, with the new alias system #4000 implemented, **kwargs will no longer be needed. We will still keep **kwargs to support single-letter option flags, but other parameters won't be passed via kwargs anymore.

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.

2 participants