Skip to content

update starlette-cramjam and update ruff #193

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

Merged
merged 2 commits into from
Oct 17, 2024
Merged
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
15 changes: 5 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions tipg/collections.py
Original file line number Diff line number Diff line change
@@ -600,9 +600,7 @@ def _sortby(self, sortby: Optional[str]):
sorts = []
if sortby:
for s in sortby.strip().split(","):
parts = re.match(
"^(?P<direction>[+-]?)(?P<column>.*)$", s
).groupdict() # type:ignore
parts = re.match("^(?P<direction>[+-]?)(?P<column>.*)$", s).groupdict() # type:ignore

direction = parts["direction"]
column = parts["column"].strip()
2 changes: 1 addition & 1 deletion tipg/dependencies.py
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@ def bbox_query(
bbox: Annotated[
Optional[str],
Query(description="Spatial Filter."),
] = None
] = None,
) -> Optional[List[float]]:
"""BBox dependency."""
if bbox:
4 changes: 1 addition & 3 deletions tipg/factory.py
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion tipg/main.py
Original file line number Diff line number Diff line change
@@ -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(
5 changes: 1 addition & 4 deletions tipg/middleware.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions tipg/model.py
Original file line number Diff line number Diff line change
@@ -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