diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1333a4b..55c3dfd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,26 +4,21 @@ repos: hooks: - id: validate-pyproject - - repo: https://github.com/psf/black - rev: 22.12.0 - hooks: - - id: black - language_version: python - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort language_version: python - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.238 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.5 hooks: - id: ruff args: ["--fix"] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.3.0 + rev: v1.11.2 hooks: - id: mypy language_version: python diff --git a/CHANGES.md b/CHANGES.md index f746a4b..6bce116 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,10 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin ## Unreleased +## [0.8.0] - TBD + +* update starlette-cramjam dependency and set compression-level default to 6 + ## [0.7.3] - 2024-09-16 * add `TIPG_SORT_COLUMNS` settings to enable/disable columns sorting (default to `True`) (author @mattdiez-at, https://github.com/developmentseed/tipg/pull/187) @@ -316,7 +320,9 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin - Initial release -[unreleased]: https://github.com/developmentseed/tipg/compare/0.7.2...HEAD +[unreleased]: https://github.com/developmentseed/tipg/compare/0.8.0...HEAD +[0.8.0]: https://github.com/developmentseed/tipg/compare/0.7.3...0.8.0 +[0.7.3]: https://github.com/developmentseed/tipg/compare/0.7.2...0.7.3 [0.7.2]: https://github.com/developmentseed/tipg/compare/0.7.1...0.7.2 [0.7.1]: https://github.com/developmentseed/tipg/compare/0.7.0...0.7.1 [0.7.0]: https://github.com/developmentseed/tipg/compare/0.6.3...0.7.0 diff --git a/pyproject.toml b/pyproject.toml index ecd5b02..cf72301 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "geojson-pydantic>=1.0,<2.0", "pygeofilter>=0.2.0,<0.3.0", "ciso8601~=2.3", - "starlette-cramjam>=0.3,<0.4", + "starlette-cramjam>=0.4,<0.5", "importlib_resources>=1.1.0; python_version < '3.9'", "typing_extensions; python_version < '3.9'", ] @@ -117,7 +117,7 @@ default_section = "THIRDPARTY" [tool.mypy] no_strict_optional = "True" -[tool.ruff] +[tool.ruff.lint] select = [ "D1", # pydocstyle errors "E", # pycodestyle errors diff --git a/tipg/collections.py b/tipg/collections.py index b003f77..05b5d5d 100644 --- a/tipg/collections.py +++ b/tipg/collections.py @@ -600,9 +600,7 @@ def _sortby(self, sortby: Optional[str]): sorts = [] if sortby: for s in sortby.strip().split(","): - parts = re.match( - "^(?P[+-]?)(?P.*)$", s - ).groupdict() # type:ignore + parts = re.match("^(?P[+-]?)(?P.*)$", s).groupdict() # type:ignore direction = parts["direction"] column = parts["column"].strip() diff --git a/tipg/dependencies.py b/tipg/dependencies.py index 4b5320f..28e8d58 100644 --- a/tipg/dependencies.py +++ b/tipg/dependencies.py @@ -189,7 +189,7 @@ def bbox_query( bbox: Annotated[ Optional[str], Query(description="Spatial Filter."), - ] = None + ] = None, ) -> Optional[List[float]]: """BBox dependency.""" if bbox: diff --git a/tipg/factory.py b/tipg/factory.py index de7efa7..a5fde58 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -776,9 +776,7 @@ async def items( # noqa: C901 MediaType.json, MediaType.ndjson, ): - if any( - [f.get("geometry", None) is not None for f in item_list["items"]] - ): + if any(f.get("geometry", None) is not None for f in item_list["items"]): rows = ( { "collectionId": collection.id, diff --git a/tipg/main.py b/tipg/main.py index 743e926..a98186e 100644 --- a/tipg/main.py +++ b/tipg/main.py @@ -101,7 +101,7 @@ async def lifespan(app: FastAPI): ) app.add_middleware(CacheControlMiddleware, cachecontrol=settings.cachecontrol) -app.add_middleware(CompressionMiddleware) +app.add_middleware(CompressionMiddleware, compression_level=6) if settings.catalog_ttl: app.add_middleware( diff --git a/tipg/middleware.py b/tipg/middleware.py index 476e436..50b6a44 100644 --- a/tipg/middleware.py +++ b/tipg/middleware.py @@ -52,10 +52,7 @@ async def send_wrapper(message: Message): scope["method"] in ["HEAD", "GET"] and message["status"] < self.cachecontrol_max_http_code and not any( - [ - re.match(path, scope["path"]) - for path in self.exclude_path - ] + re.match(path, scope["path"]) for path in self.exclude_path ) ): response_headers["Cache-Control"] = self.cachecontrol diff --git a/tipg/model.py b/tipg/model.py index 442e49b..cab89da 100644 --- a/tipg/model.py +++ b/tipg/model.py @@ -236,9 +236,9 @@ class Queryables(BaseModel): title: str properties: Dict[str, Dict[str, str]] type: str = "object" - schema_name: Annotated[ - str, Field(alias="$schema") - ] = "https://json-schema.org/draft/2019-09/schema" + schema_name: Annotated[str, Field(alias="$schema")] = ( + "https://json-schema.org/draft/2019-09/schema" + ) link: Annotated[str, Field(alias="$id")] model_config = {"populate_by_name": True} @@ -391,9 +391,9 @@ class BoundingBox(BaseModel): ), ] crs: Annotated[Optional[CRSType], Field(json_schema_extra={"title": "CRS"})] = None - orderedAxes: Annotated[ - Optional[List[str]], Field(max_length=2, min_length=2) - ] = None + orderedAxes: Annotated[Optional[List[str]], Field(max_length=2, min_length=2)] = ( + None + ) # Ref: https://github.com/opengeospatial/ogcapi-tiles/blob/master/openapi/schemas/tms/propertiesSchema.yaml