Skip to content

Commit

Permalink
ci: Replace flake8 with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
rht authored and tpike3 committed Jan 29, 2023
1 parent 8e9617e commit 912dfbf
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

11 changes: 6 additions & 5 deletions .github/workflows/build_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ jobs:
name: Codecov
uses: codecov/codecov-action@v3

lint-flake:
lint-ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install flake8
- name: Lint with flake8
# Use settings from mesas .flake8 file
run: flake8 . --count --show-source --statistics
- run: pip install ruff
- name: Lint with ruff
# Include `--format=github` to enable automatic inline annotations.
# Use settings from pyproject.toml.
run: ruff . --format=github --extend-exclude mesa/cookiecutter-mesa/*

lint-black:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ If you're changing previous Mesa features, please make sure of the following:
- Additional features or rewrites of current features are accompanied by tests.
- New features are demonstrated in a model, so folks can understand more easily.

To ensure that your submission will not break the build, you will need to install Flake8 and pytest.
To ensure that your submission will not break the build, you will need to install Ruff and pytest.

.. code-block:: bash
pip install flake8 pytest pytest-cov
pip install ruff pytest pytest-cov
We test by implementing simple models and through traditional unit tests in the tests/ folder. The following only covers unit tests coverage. Ensure that your test coverage has not gone down. If it has and you need help, we will offer advice on how to structure tests for the contribution.

Expand All @@ -91,7 +91,7 @@ You should no longer have to worry about code formatting. If still in doubt you

.. code-block:: bash
flake8 . --ignore=F403,E501,E123,E128,W504,W503 --exclude=docs,build
ruff .
.. _`PEP8` : https://www.python.org/dev/peps/pep-0008
Expand Down
2 changes: 1 addition & 1 deletion mesa/visualization/UserParam.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(
valid = True

if self.param_type == self.NUMBER:
valid = not (self.value is None)
valid = self.value is not None

elif self.param_type == self.SLIDER:
valid = not (
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.ruff]
# Ignore list taken from https://github.com/psf/black/blob/master/.flake8
# E203 Whitespace before ':'
# E266 Too many leading '#' for block comment
# E501 Line too long (82 > 79 characters)
# W503 Line break occurred before a binary operator
# But we don't specify them because ruff's Black already
# checks for it.
# See https://github.com/charliermarsh/ruff/issues/1842#issuecomment-1381210185
extend-ignore = ["E501"]
extend-exclude = ["docs", "build"]
# Hardcode to Python 3.10.
target-version = "py310"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
requires = ["click", "cookiecutter", "networkx", "numpy", "pandas", "tornado", "tqdm"]

extras_require = {
"dev": ["black", "coverage", "flake8", "pytest >= 4.6", "pytest-cov", "sphinx"],
"dev": ["black", "ruff", "coverage", "pytest >= 4.6", "pytest-cov", "sphinx"],
"docs": ["sphinx", "ipython"],
}

Expand Down

0 comments on commit 912dfbf

Please sign in to comment.