Skip to content
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

Formatting via ruff #662

Merged
merged 6 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 5 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ review the [contributing procedures](https://github.com/pysal/pysal/wiki/GitHub-

## Style and format

1. Python 3.6, 3.7, and 3.8 are the officially supported versions.
2. This project follows the formatting conventions of [`black`](https://black.readthedocs.io/en/stable/) and utilizes [`pre-commit`](https://pre-commit.com) to format commits prior to pull requests being made.
* LJ Miranda provides an [excellent, concise guide](https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/) on setting up and implementing a `pre-commit` hook for `black`.
1. At the time of this writing, Python 3.10, 3.11, and 3.12 are the officially supported versions.
2. This project implements the linting and formatting conventions of [`ruff`](https://docs.astral.sh/ruff/) on all incoming Pull Requests. To ensure a PR is properly linted and formatted prior to creating a Pull Request, [install `pre-commit`](https://pre-commit.com/#installation) in your development environment and then [set up the `libpysal` configuration of pre-commit hooks](https://pre-commit.com/#3-install-the-git-hook-scripts).



6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
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
- id: ruff-format

ci:
autofix_prs: false
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
============

libpysal supports python >= `3.8`_ only. Please make sure that you are
libpysal supports python >= `3.10`_ only. Please make sure that you are
operating in a python 3 environment.

Installing released version
Expand Down Expand Up @@ -50,7 +50,7 @@ to your local clone and submitting a pull request to `pysal/libpysal`_, you can
contribute to libpysal development.


.. _3.8: https://docs.python.org/3.8/
.. _3.10: https://docs.python.org/3.10/
.. _Python Package Index: https://pypi.org/project/libpysal/
.. _pysal/libpysal: https://github.com/pysal/libpysal
.. _fork: https://help.github.com/articles/fork-a-repo/
3 changes: 2 additions & 1 deletion libpysal/cg/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ def get_polygon_point_dist(poly, pt):
for vertices in poly._vertices:
vx_range = range(-1, len(vertices) - 1)
seg = lambda i: LineSegment( # noqa: E731
vertices[i], vertices[i + 1] # noqa: B023
vertices[i], # noqa: B023
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)
Expand Down
6 changes: 3 additions & 3 deletions libpysal/graph/tests/test_contiguity.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,16 @@ def test_block_contiguity(regimes):
8: [4, 5],
9: [],
}
assert {f: n.tolist() for f, n, in neighbors.items()} == wn
assert {f: n.tolist() for f, n in neighbors.items()} == wn

ids = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
neighbors = _block_contiguity(regimes, ids=ids)
wn_str = {ids[f]: [ids[o] for o in n] for f, n in wn.items()}
assert {f: n.tolist() for f, n, in neighbors.items()} == wn_str
assert {f: n.tolist() for f, n in neighbors.items()} == wn_str

regimes = pandas.Series(regimes, index=ids)
neighbors = _block_contiguity(regimes)
assert {f: n.tolist() for f, n, in neighbors.items()} == wn_str
assert {f: n.tolist() for f, n in neighbors.items()} == wn_str


def test_fuzzy_contiguity():
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ tests = [
[tool.setuptools.packages.find]
include = ["libpysal", "libpysal.*"]

[tool.black]
line-length = 88

[tool.ruff]
line-length = 88
select = ["E", "F", "W", "I", "UP", "N", "B", "A", "C4", "SIM", "ARG"]
Expand Down