Skip to content
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

change STACTypeError to create short informative message #1126

Merged
merged 1 commit into from
May 26, 2023

Conversation

ircwaves
Copy link
Member

@ircwaves ircwaves commented May 18, 2023

Related Issue(s):

Description:

This creates a standardized message (which doesn't blow out the console) for STACTypeErrors.

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run scripts/test)
  • Documentation has been updated to reflect changes, if applicable
  • This PR maintains or improves overall codebase code coverage.
  • Changes are added to the CHANGELOG. See the docs for information about adding to the changelog.

@ircwaves ircwaves requested a review from gadomski May 18, 2023 14:41
@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (e196e50) 90.38% compared to head (b9b6346) 90.42%.

❗ Current head b9b6346 differs from pull request most recent head e988e24. Consider uploading reports for the commit e988e24 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1126      +/-   ##
==========================================
+ Coverage   90.38%   90.42%   +0.03%     
==========================================
  Files          48       48              
  Lines        6367     6330      -37     
  Branches      947      941       -6     
==========================================
- Hits         5755     5724      -31     
+ Misses        431      428       -3     
+ Partials      181      178       -3     
Impacted Files Coverage Δ
pystac/catalog.py 93.33% <100.00%> (+0.42%) ⬆️
pystac/collection.py 95.40% <100.00%> (+0.64%) ⬆️
pystac/errors.py 100.00% <100.00%> (ø)
pystac/item.py 93.59% <100.00%> (+0.77%) ⬆️
pystac/item_collection.py 91.54% <100.00%> (ø)
pystac/serialization/identify.py 90.90% <100.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gadomski gadomski added this to the 1.8 milestone May 18, 2023
@ircwaves ircwaves force-pushed the clean-stactypeerror-message branch from 687285b to f83c4a3 Compare May 18, 2023 20:21
pystac/errors.py Outdated Show resolved Hide resolved
tests/data-files/catalogs/test-case-9/catalog.json Outdated Show resolved Hide resolved
@ircwaves ircwaves force-pushed the clean-stactypeerror-message branch from f83c4a3 to e768a3d Compare May 23, 2023 17:54
Copy link
Member Author

@ircwaves ircwaves left a comment

Choose a reason for hiding this comment

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

Adjustments made.

pystac/errors.py Outdated Show resolved Hide resolved
tests/data-files/catalogs/test-case-9/catalog.json Outdated Show resolved Hide resolved
@ircwaves ircwaves requested a review from gadomski May 23, 2023 17:55
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

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

So this is a little annoying, but the Catalog.from_file error message isn't quite what I'd expect. Code (run from root):

from pathlib import Path

from pystac import Catalog

path = (
    Path(__file__).parent
    / "tests"
    / "data-files"
    / "catalogs"
    / "invalid-catalog"
    / "catalog.json"
)
Catalog.from_file(str(path))

results in

pystac.errors.STACTypeError: JSON (id = broken_cat) does not represent a STACObject instance.

It's way better than it was, but the best text would end with "...a Catalog instance". Is there any way to get the "final" class type into the message in those STACObject alternate-constructor methods?

@ircwaves
Copy link
Member Author

ircwaves commented May 25, 2023

It's way better than it was, but the best text would end with "...a Catalog instance". Is there any way to get the "final" class type into the message in those STACObject alternate-constructor methods?

I thought that there was only one case where that should happen, and not that one. Let me take a look.

pystac/errors.py Outdated Show resolved Hide resolved
@ircwaves ircwaves force-pushed the clean-stactypeerror-message branch from b9b6346 to e988e24 Compare May 25, 2023 18:59
@ircwaves ircwaves requested a review from gadomski May 25, 2023 20:17
@gadomski gadomski added this pull request to the merge queue May 26, 2023
Merged via the queue into stac-utils:main with commit d1532c9 May 26, 2023
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