Skip to content

Commit

Permalink
Merge branch 'main' into unpin-urllib3
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski authored Oct 25, 2023
2 parents 45e6153 + 0ba5d7a commit 8918156
Show file tree
Hide file tree
Showing 52 changed files with 16,087 additions and 8,723 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- windows-latest
- macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -48,7 +48,7 @@ jobs:
name: min-versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.9
Expand All @@ -68,7 +68,7 @@ jobs:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Conda Environment
uses: conda-incubator/[email protected]
with:
Expand All @@ -87,7 +87,7 @@ jobs:
name: pre-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.9
Expand All @@ -104,7 +104,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.9
Expand All @@ -120,7 +120,7 @@ jobs:
name: dev and docs requirements check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.9
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.278"
rev: "v0.0.285"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -25,7 +25,7 @@ repos:
additional_dependencies:
- importlib_metadata < 5; python_version == "3.7"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v1.5.1
hooks:
- id: mypy
files: ".*\\.py$"
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v0.7.5] - 2023-09-05

### Fixed

- `--matched` flag in CLI [#588](https://github.com/stac-utils/pystac-client/pull/588)

## [v0.7.4] - 2023-09-05

### Changed

- Don't provide a `limit` by default, trust the server to know its limits [#584](https://github.com/stac-utils/pystac-client/pull/584)

## [v0.7.3] - 2023-08-21

### Changed

- Raise more informative errors from CLI [#554](https://github.com/stac-utils/pystac-client/pull/554)
Expand Down Expand Up @@ -320,7 +334,10 @@ are in a single HTTP session, handle pagination and respects conformance

Initial release.

[Unreleased]: <https://github.com/stac-utils/pystac-client/compare/v0.7.2...main>
[Unreleased]: <https://github.com/stac-utils/pystac-client/compare/v0.7.5...main>
[v0.7.5]: <https://github.com/stac-utils/pystac-client/compare/v0.7.4...v0.7.5>
[v0.7.4]: <https://github.com/stac-utils/pystac-client/compare/v0.7.3...v0.7.4>
[v0.7.3]: <https://github.com/stac-utils/pystac-client/compare/v0.7.2...v0.7.3>
[v0.7.2]: <https://github.com/stac-utils/pystac-client/compare/v0.7.1...v0.7.2>
[v0.7.1]: <https://github.com/stac-utils/pystac-client/compare/v0.7.0...v0.7.1>
[v0.7.0]: <https://github.com/stac-utils/pystac-client/compare/v0.6.1...v0.7.0>
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ the library as an "editable link", then install the development dependencies:
.. code-block:: bash
$ git clone [email protected]:your_user_name/pystac-client.git
$ cd pystac
$ cd pystac-client
$ pip install -e '.[dev]'
Testing
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dev = [
"pytest~=7.4",
"recommonmark~=0.7.1",
"requests-mock~=1.11.0",
"ruff==0.0.285",
"ruff==0.1.2",
"tomli~=2.0; python_version<'3.11'",
"types-python-dateutil~=2.8.19",
"types-requests~=2.31.0",
Expand All @@ -63,13 +63,13 @@ docs = [
"boto3~=1.26",
"cartopy~=0.21",
"geojson~=3.0.1",
"geopandas~=0.13.0",
"geopandas~=0.14.0",
"geoviews~=1.9",
"hvplot~=0.8.3",
"hvplot~=0.9.0",
"ipykernel~=6.22",
"ipython~=8.12",
"jinja2<4.0",
"matplotlib~=3.7.1",
"matplotlib~=3.8",
"myst-parser~=2.0",
"nbsphinx~=0.9",
"pydata-sphinx-theme~=0.13",
Expand Down
52 changes: 43 additions & 9 deletions pystac_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@

from .client import Client
from .conformance import ConformanceClasses
from .item_search import OPS
from .item_search import (
OPS,
BBoxLike,
CollectionsLike,
DatetimeLike,
FieldsLike,
FilterLangLike,
FilterLike,
IDsLike,
IntersectsLike,
QueryLike,
SortbyLike,
)
from .version import __version__
from .warnings import (
DoesNotConformTo,
Expand All @@ -26,21 +38,43 @@

def search(
client: Client,
method: str = "GET",
matched: bool = False,
save: Optional[str] = None,
**kwargs: Dict[str, Any],
*,
method: str = "GET",
max_items: Optional[int] = None,
limit: Optional[int] = None,
ids: Optional[IDsLike] = None,
collections: Optional[CollectionsLike] = None,
bbox: Optional[BBoxLike] = None,
intersects: Optional[IntersectsLike] = None,
datetime: Optional[DatetimeLike] = None,
query: Optional[QueryLike] = None,
filter: Optional[FilterLike] = None,
filter_lang: Optional[FilterLangLike] = None,
sortby: Optional[SortbyLike] = None,
fields: Optional[FieldsLike] = None,
) -> int:
"""Main function for performing a search"""

# https://github.com/python/mypy/issues/4441
# the type: ignore is to silence the mypy error
# error: Argument 2 to "search" of "Client" has incompatible
# type "**Dict[str, Dict[str, Any]]"; expected "Optional[int]" [arg-type]
result = client.search(method=method, **kwargs) # type: ignore[arg-type]
result = client.search(
method=method,
max_items=max_items,
limit=limit,
ids=ids,
collections=collections,
bbox=bbox,
intersects=intersects,
datetime=datetime,
query=query,
filter=filter,
filter_lang=filter_lang,
sortby=sortby,
fields=fields,
)

if matched:
if nmatched := result.matched() is not None:
if (nmatched := result.matched()) is not None:
print(f"{nmatched} items matched")
else:
raise KeyError("'matched' is not supported for this catalog")
Expand Down
5 changes: 2 additions & 3 deletions pystac_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from pystac_client.errors import ClientTypeError
from pystac_client.exceptions import APIError
from pystac_client.item_search import (
DEFAULT_LIMIT_AND_MAX_ITEMS,
BBoxLike,
CollectionsLike,
DatetimeLike,
Expand Down Expand Up @@ -475,7 +474,7 @@ def search(
*,
method: Optional[str] = "POST",
max_items: Optional[int] = None,
limit: Optional[int] = DEFAULT_LIMIT_AND_MAX_ITEMS,
limit: Optional[int] = None,
ids: Optional[IDsLike] = None,
collections: Optional[CollectionsLike] = None,
bbox: Optional[BBoxLike] = None,
Expand Down Expand Up @@ -590,7 +589,7 @@ def search(

if not self.conforms_to(ConformanceClasses.ITEM_SEARCH):
raise DoesNotConformTo(
"ITEM_SEARCH", "There is not fallback option available for search."
"ITEM_SEARCH", "There is no fallback option available for search."
)

return ItemSearch(
Expand Down
17 changes: 10 additions & 7 deletions pystac_client/item_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ def __geo_interface__(self) -> Dict[str, Any]:

OPS = list(OP_MAP.keys())

# Previously named DEFAULT_LIMIT_AND_MAX_ITEMS
# aliased for backwards compat
# https://github.com/stac-utils/pystac-client/pull/273
DEFAUL_LIMIT = DEFAULT_LIMIT_AND_MAX_ITEMS = 100

def __getattr__(name: str) -> Any:
if name in ("DEFAUL_LIMIT", "DEFAULT_LIMIT_AND_MAX_ITEMS"):
warnings.warn(
f"{name} is deprecated and will be removed in v0.8", DeprecationWarning
)
return 100
raise AttributeError(f"module {__name__} has no attribute {name}")


# from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9#gistcomment-2622319
Expand Down Expand Up @@ -172,8 +176,7 @@ class ItemSearch:
*per page* of results. Defaults to 100.
ids: List of one or more Item ids to filter on.
collections: List of one or more Collection IDs or :class:`pystac.Collection`
instances. Only Items in one
of the provided Collections will be searched
instances.
bbox: A list, tuple, or iterator representing a bounding box of 2D
or 3D coordinates. Results will be filtered
to only those intersecting the bounding box.
Expand Down Expand Up @@ -258,7 +261,7 @@ def __init__(
max_items: Optional[int] = None,
stac_io: Optional[StacApiIO] = None,
client: Optional["_client.Client"] = None,
limit: Optional[int] = DEFAULT_LIMIT_AND_MAX_ITEMS,
limit: Optional[int] = None,
ids: Optional[IDsLike] = None,
collections: Optional[CollectionsLike] = None,
bbox: Optional[BBoxLike] = None,
Expand Down
2 changes: 1 addition & 1 deletion pystac_client/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.2"
__version__ = "0.7.5"
Loading

0 comments on commit 8918156

Please sign in to comment.