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

rename ConformanceClasses to Conformance #136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

3.1.0 (TBD)
-----------------
- Remove the deprecated `Context` extension (#138, @vincentsarago)
- Rename `stac_pydantic.api.conformance.ConformanceClasses` to `stac_pydantic.api.conformance.Conformance`
- Update pre-commit configuration and switch to astral-sh/ruff for linter and formater
- Add official support for python 3.12

Expand Down
30 changes: 28 additions & 2 deletions stac_pydantic/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
# flake8: noqa: F401
"""STAC API models."""

import warnings

from .collection import Collection
from .collections import Collections
from .conformance import ConformanceClasses
from .conformance import Conformance
from .item import Item
from .item_collection import ItemCollection
from .landing import LandingPage
from .search import Search

__all__ = [
"Collection",
"Collections",
"Conformance",
"Item",
"ItemCollection",
"LandingPage",
"Search",
]


# TODO: remove in 4.0
def __getattr__(name):
if name == "ConformanceClasses":
warnings.warn(
"Class `ConformanceClasses` has been renamed to `Conformance`. Please use the new name. The old alias will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)
return Conformance

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
2 changes: 1 addition & 1 deletion stac_pydantic/api/conformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import AnyHttpUrl, BaseModel


class ConformanceClasses(BaseModel):
class Conformance(BaseModel):
"""
https://github.com/radiantearth/stac-api-spec/blob/master/api-spec.md#ogc-api---features-endpoints
"""
Expand Down
11 changes: 8 additions & 3 deletions tests/api/test_conformance.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import pytest
from pydantic import ValidationError

from stac_pydantic.api.conformance import ConformanceClasses
from stac_pydantic.api.conformance import Conformance


def test_deprecation():
with pytest.warns(DeprecationWarning):
from stac_pydantic.api import ConformanceClasses # noqa


def test_api_conformance():
ConformanceClasses(
Conformance(
conformsTo=["https://conformance-class-1", "http://conformance-class-2"]
)


def test_api_conformance_invalid_url():
with pytest.raises(ValidationError):
ConformanceClasses(conformsTo=["s3://conformance-class"])
Conformance(conformsTo=["s3://conformance-class"])
Loading