pytroll / pyresample

Geospatial image resampling in Python
http://pyresample.readthedocs.org
GNU Lesser General Public License v3.0
343 stars 95 forks source link

Fix area definition YAML not warning on typos #577

Closed djhoese closed 5 months ago

djhoese commented 6 months ago

If a user has a typo or some other unused parameter in an area YAML definition then pyresample silently ignores it and the user is left confused as to why things aren't working as expected. This PR fixes this by producing a UserWarning in these cases.

I could make this an error but I feel that limits the future flexibility and maintainability of the YAML reading. I could also make a configuration (pyresample.config) parameter that controls whether this is a warnings or error...or maybe just another keyword argument, but I'm not sure we need any more kwargs for these functions.

TODO: I'd like to rework some of the metadata handling in the future area definitions. I might not do that in this PR as it is decently separate. I noticed while working on this that any unused kwarg is put into the future AreaDefinition's .attrs dictionary property. This is error prone as it means that any unrecognized property will go in as "metadata". I'd like to add an explicit attrs: section to the YAML for defining these metadata values.

codecov[bot] commented 6 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (eaf8367) 94.05% compared to head (26d8dc9) 94.06%.

Files Patch % Lines
pyresample/area_config.py 92.85% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #577 +/- ## ======================================= Coverage 94.05% 94.06% ======================================= Files 90 90 Lines 13575 13590 +15 ======================================= + Hits 12768 12783 +15 Misses 807 807 ``` | [Flag](https://app.codecov.io/gh/pytroll/pyresample/pull/577/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/pytroll/pyresample/pull/577/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `94.06% <95.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

coveralls commented 6 months ago

Coverage Status

coverage: 93.656% (+0.007%) from 93.649% when pulling 26d8dc9ffea947ad1c73b9b9e03da335b1a42acb on djhoese:warn-unused-area-params into eaf8367a0554cb43c570caaf0e311bf1f3e8c17d on pytroll:main.