From 1f10c3ffb784da4bc92eb466de49458f5e544fea Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Tue, 21 Nov 2023 20:04:17 -0500 Subject: [PATCH 1/2] final run through & update pre-commit --- .pre-commit-config.yaml | 21 +++++++++++++++------ libpysal/cg/standalone.py | 4 +++- libpysal/graph/_kernel.py | 4 ++-- libpysal/io/fileio.py | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bef3987e3..8696b2fa0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,15 @@ -repos: -- repo: https://github.com/psf/black - rev: "23.10.0" - hooks: - - id: black - language_version: python3 +files: "libpysal\/" +repos: + - repo: https://github.com/psf/black + rev: "23.10.1" + hooks: + - id: black + language_version: python3 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.1.6" + hooks: + - id: ruff + +ci: + autofix_prs: false + autoupdate_schedule: quarterly diff --git a/libpysal/cg/standalone.py b/libpysal/cg/standalone.py index f94088740..42c626b16 100644 --- a/libpysal/cg/standalone.py +++ b/libpysal/cg/standalone.py @@ -634,7 +634,9 @@ def get_polygon_point_dist(poly, pt): part_prox = [] for vertices in poly._vertices: vx_range = range(-1, len(vertices) - 1) - seg = lambda i: LineSegment(vertices[i], vertices[i + 1]) # noqa: B023 + seg = lambda i: LineSegment( # noqa: E731 + vertices[i], vertices[i + 1] # noqa: B023 + ) _min_dist = min([get_segment_point_dist(seg(i), pt)[0] for i in vx_range]) part_prox.append(_min_dist) dist = min(part_prox) diff --git a/libpysal/graph/_kernel.py b/libpysal/graph/_kernel.py index 8c63e1fba..c68f99a57 100644 --- a/libpysal/graph/_kernel.py +++ b/libpysal/graph/_kernel.py @@ -254,14 +254,14 @@ def _knn(coordinates, metric="euclidean", k=1, p=2, coincident="raise"): coincident="jitter", ) - if (coincident == "clique"): + if coincident == "clique": heads, tails, weights = _sparse_to_arrays( _knn( coincident_lut.geometry, metric=metric, k=k, p=p, coincident="raise" ) ) adjtable = pandas.DataFrame.from_dict( - dict(focal=heads, neighbor=tails, weight=weights) + {"focal": heads, "neighbor": tails, "weight": weights} ) adjtable = _induce_cliques(adjtable, coincident_lut, fill_value=-1) adjtable = _reorder_adjtable_by_ids(adjtable, ids) diff --git a/libpysal/io/fileio.py b/libpysal/io/fileio.py index fa3f88b7a..fbe06007d 100644 --- a/libpysal/io/fileio.py +++ b/libpysal/io/fileio.py @@ -146,7 +146,7 @@ def check(cls): print(f"Ext: '.{key}', Modes: {list(val.keys())!r}") @classmethod - def open(cls, *args, **kwargs): # noqa: A001 + def open(cls, *args, **kwargs): # noqa: A001, A003 """Alias for ``FileIO()``.""" return cls(*args, **kwargs) From 074004bfeaeded53a7bca6bb285987a224c1f5f7 Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Wed, 22 Nov 2023 10:08:41 -0500 Subject: [PATCH 2/2] no global ignore --- pyproject.toml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c9688bf6f..31d5aa759 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,18 +86,6 @@ line-length = 88 line-length = 88 select = ["E", "F", "W", "I", "UP", "N", "B", "A", "C4", "SIM", "ARG"] target-version = "py310" -ignore = [ - "B006", - "B008", - "B009", - "B010", - "C408", - "E731", - "N803", - "N806", - "N999", - "UP007" -] exclude = ["libpysal/tests/*", "docs/*"] [tool.ruff.per-file-ignores] "*__init__.py" = [