Skip to content

Commit

Permalink
update pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Oct 1, 2024
1 parent d84f9ec commit 5543b42
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 111 deletions.
9 changes: 0 additions & 9 deletions .bumpversion.cfg

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ on:
- '*'
pull_request:
env:
LATEST_PY_VERSION: '3.10'
LATEST_PY_VERSION: '3.12'

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -53,9 +53,9 @@ jobs:
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ env.LATEST_PY_VERSION }}

Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/deploy_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Install dependencies
run: |
Expand Down
14 changes: 4 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
hooks:
- id: isort
language_version: python

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.270
- 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.4.1
rev: v1.11.2
hooks:
- id: mypy
language_version: python
Expand All @@ -33,4 +28,3 @@ repos:
- types-attrs
- types-cachetools
- types-setuptools
- pydantic~=2.0
1 change: 0 additions & 1 deletion cogeo_mosaic/backends/memory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""cogeo-mosaic In-Memory backend."""


import attr

from cogeo_mosaic.backends.base import BaseBackend
Expand Down
10 changes: 3 additions & 7 deletions cogeo_mosaic/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def default_filter(
indices = list(range(len(dataset)))

if minimum_tile_cover or tile_cover_sort:
tile_geom = polygons(
WEB_MERCATOR_TMS.feature(tile)["geometry"]["coordinates"][0]
)
tile_geom = polygons(WEB_MERCATOR_TMS.feature(tile)["geometry"]["coordinates"][0])
int_pcts = _intersect_percent(tile_geom, geoms)

if minimum_tile_cover:
Expand All @@ -50,7 +48,7 @@ def default_filter(

if tile_cover_sort:
# https://stackoverflow.com/a/9764364
_, indices = zip(*sorted(zip(int_pcts, indices), reverse=True))
_, indices = zip(*sorted(zip(int_pcts, indices), reverse=True)) # type: ignore

if maximum_items_per_tile:
indices = indices[:maximum_items_per_tile]
Expand Down Expand Up @@ -208,9 +206,7 @@ def _create_mosaic(
) as bar:
for tile in bar:
quadkey = tms.quadkey(tile)
tile_geom = polygons(
tms.feature(tile)["geometry"]["coordinates"][0]
)
tile_geom = polygons(tms.feature(tile)["geometry"]["coordinates"][0])

# Find intersections from rtree
intersections_idx = sorted(
Expand Down
25 changes: 23 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ test = [
"pytest", "pytest-cov", "boto3",
]
dev = [
"pytest", "pytest-cov", "pre-commit"
"pre-commit",
"bump-my-version",
]
docs = [
"mkdocs", "mkdocs-material", "pygments", "mkdocs-jupyter"
Expand Down Expand Up @@ -127,6 +128,9 @@ default_section = "THIRDPARTY"
no_strict_optional = "True"

[tool.ruff]
line-length = 90

[tool.ruff.lint]
select = [
"D1", # pydocstyle errors
"E", # pycodestyle errors
Expand All @@ -142,5 +146,22 @@ ignore = [
"B028", # ignore No explicit stacklevel keyword argument found
]

[tool.ruff.extend-per-file-ignores]
[tool.ruff.lint.mccabe]
max-complexity = 14

[tool.ruff.lint.extend-per-file-ignores]
"tests/*.py" = ["D1"]

[tool.bumpversion]
current_version = "7.1.0"
search = "{current_version}"
replace = "{new_version}"
regex = false
tag = true
commit = true
tag_name = "{new_version}"

[[tool.bumpversion.files]]
filename = "cogeo_mosaic/__init__.py]"
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
Loading

0 comments on commit 5543b42

Please sign in to comment.