Skip to content

Fix TypeError in KINEROS exporter's incremental option check - #582

Open
syahra712 wants to merge 1 commit into
pySTEPS:masterfrom
syahra712:fix-kineros-incremental-error-message
Open

syahra712 wants to merge 1 commit into
pySTEPS:masterfrom
syahra712:fix-kineros-incremental-error-message

Conversation

@syahra712

Copy link
Copy Markdown

initialize_forecast_exporter_kineros is meant to reject incremental with a ValueError, but the message is built as

"unknown option %s: " + "incremental writing is not supported" % incremental

% binds tighter than +, so the formatting is applied to the second literal, which has no placeholder. Passing e.g. incremental="timestep" therefore raises TypeError: not all arguments converted during string formatting instead of the intended error.

This merges the two literals so the message formats as unknown option timestep: incremental writing is not supported, and adds a test in test_exporters.py that checks the ValueError is raised.

The % operator bound to the second string literal only, which has no
placeholder, so passing incremental raised 'not all arguments converted
during string formatting' instead of the intended ValueError.

This branch has not been deployed

No deployments
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