diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a1fc6e..1f49444 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: 3.x - - run: pip install black ruff mypy + - run: pip install ruff mypy - run: make lint docs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 916b18f..46c1f00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ## Unreleased +### Changed * Python >=3.9 required ## [1.6](https://pypi.org/project/django-model-values/1.6/) - 2023-11-04 diff --git a/Makefile b/Makefile index 91da7de..71aae8f 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ check: python -m pytest -s --cov lint: - black --check . ruff . + ruff format --check . mypy -p model_values html: diff --git a/README.md b/README.md index 8f117bd..f65b7e5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ [![image](https://github.com/coady/django-model-values/workflows/build/badge.svg)](https://github.com/coady/django-model-values/actions) [![image](https://codecov.io/gh/coady/django-model-values/branch/main/graph/badge.svg)](https://codecov.io/gh/coady/django-model-values/) [![image](https://github.com/coady/django-model-values/workflows/codeql/badge.svg)](https://github.com/coady/django-model-values/security/code-scanning) -[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://pypi.org/project/black/) [![image](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![image](https://mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/) diff --git a/model_values/__init__.py b/model_values/__init__.py index ea87ffe..3bef9ef 100644 --- a/model_values/__init__.py +++ b/model_values/__init__.py @@ -580,7 +580,9 @@ def bulk_changed(self, field, data: Mapping, key: str = 'pk') -> dict: rows = self.filter(F(key).isin(data))[key, field].iterator() return {pk: value for pk, value in rows if value != data[pk]} - def bulk_change(self, field, data: Mapping, key: str = 'pk', conditional=False, **kwargs) -> int: + def bulk_change( + self, field, data: Mapping, key: str = 'pk', conditional=False, **kwargs + ) -> int: """Update changed rows with a minimal number of queries, by inverting the data to use ``pk__in``. Args: diff --git a/pyproject.toml b/pyproject.toml index 9e1facd..a92a810 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,12 +45,12 @@ version = {attr = "model_values.__version__"} [tool.setuptools.package-data] model_values = ["py.typed"] -[tool.black] -line-length = 110 -skip-string-normalization = true - [tool.ruff] -ignore = ["E501"] +line-length = 100 + +[tool.ruff.format] +preview = true +quote-style = "preserve" [[tool.mypy.overrides]] module = ["django.*"] diff --git a/tests/conftest.py b/tests/conftest.py index efd3b59..a5ecb04 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,4 +7,6 @@ def pytest_report_header(config): pytest_plugins = ('django',) -settings.configure(INSTALLED_APPS=['tests'], DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}}) +settings.configure( + INSTALLED_APPS=['tests'], DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}} +) diff --git a/tests/test_all.py b/tests/test_all.py index 3a52d6a..4acc0d3 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -317,7 +317,8 @@ def test_spatial_lookups(): point = 'POINT(0 0)' assert F.location.is_valid.children == [('location__isvalid', True)] assert F.location.contains(point, bb=True).children == [('location__bbcontains', point)] - assert F.location.contains(point, properly=True).children == [('location__contains_properly', point)] + expected = [('location__contains_properly', point)] + assert F.location.contains(point, properly=True).children == expected assert F.location.overlaps(point).children == [('location__overlaps', point)] assert F.location.overlaps(point, bb=True).children == [('location__bboverlaps', point)] @@ -339,8 +340,10 @@ def test_spatial_lookups(): assert F.location.relate(point, '').children == [('location__relate', (point, ''))] assert F.location.touches(point).children == [('location__touches', point)] - assert (F.location << point).children == F.location.left(point).children == [('location__left', point)] - assert (F.location >> point).children == F.location.right(point).children == [('location__right', point)] + expected = [('location__left', point)] + assert (F.location << point).children == F.location.left(point).children == expected + expected = [('location__right', point)] + assert (F.location >> point).children == F.location.right(point).children == expected assert F.location.above(point).children == [('location__strictly_above', point)] assert F.location.below(point).children == [('location__strictly_below', point)] @@ -374,7 +377,8 @@ def test_spatial_functions(books): dist = F.location.distance(point) assert isinstance(dist, gis.functions.Distance) - fields, items = zip(*F.all([(dist < 0), (dist <= 0), (dist > 0), (dist >= 0), dist.within(0)]).children) + dists = (dist < 0), (dist <= 0), (dist > 0), (dist >= 0), dist.within(0) + fields, items = zip(*F.all(dists).children) assert fields == ( 'location__distance_lt', 'location__distance_lte',