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

Switch repository formatting to ruff #433

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*.ipynb linguist-language=Python
spopt/_version.py export-subst
6 changes: 2 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ Thank you for your interest in contributing! We work primarily on Github. Please

## Style and format

This project utilizes:
* [`black`](https://black.readthedocs.io/en/stable/) for formatting;
* [`ruff`](https://docs.astral.sh/ruff/) for linting; and
* [`pre-commit`](https://pre-commit.com) to check format and lint on commits prior to pull requests being made.
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 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: "spopt\/"
repos:
- repo: https://github.com/psf/black
rev: "23.11.0"
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![codecov](https://codecov.io/gh/pysal/spopt/branch/main/graph/badge.svg)](https://codecov.io/gh/pysal/spopt)
[![Documentation](https://img.shields.io/static/v1.svg?label=docs&message=current&color=9cf)](http://pysal.org/spopt/)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![status](https://joss.theoj.org/papers/1413cf2c0cf3c561386949f2e1208563/status.svg)](https://joss.theoj.org/papers/1413cf2c0cf3c561386949f2e1208563)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4444156.svg)](https://doi.org/10.5281/zenodo.4444156)

Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ tests = [
"pytest-cov",
"pytest-xdist",
]
dev = ["pre-commit"]
dev = ["pre-commit", "ruff"]
docs = [
"nbsphinx",
"numpydoc",
Expand All @@ -79,13 +79,9 @@ notebooks = [
[tool.setuptools.packages.find]
include = ["spopt", "spopt.*"]

[tool.black]
line-length = 88

[tool.ruff]
line-length = 88
select = ["E", "F", "W", "I", "UP", "N", "B", "A", "C4", "SIM", "ARG"]
target-version = "py310"
exclude = ["spopt/tests/*", "docs/*"]

[tool.ruff.per-file-ignores]
Expand Down
6 changes: 5 additions & 1 deletion spopt/region/azp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

class AllowMoveStrategy(abc.ABC):
def start_new_component(
self, initial_labels, attr, objective_func, comp_idx # noqa: ARG002
self,
initial_labels,
attr,
objective_func,
comp_idx, # noqa: ARG002
):
"""
This method should be called whenever a new connected component is
Expand Down