Skip to content

Commit

Permalink
ci: Replace flake8 & Black with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
rht committed Jan 21, 2023
1 parent e3cc4d4 commit e29c3d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/build_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,15 @@ 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

lint-black:
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 black[jupyter]
- name: Lint with black
run: black --check --exclude=mesa/cookiecutter-mesa/* .
- run: pip install ruff
- name: Lint with ruff
# Use settings from pyproject.toml
run: ruff . --extend-exclude mesa/cookiecutter-mesa/*
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
8 changes: 5 additions & 3 deletions .flake8 → pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[flake8]
[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
ignore = E203, E266, E501, W503
exclude = docs, build
# 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-exclude = ["docs", "build"]
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": ["ruff", "coverage", "pytest >= 4.6", "pytest-cov", "sphinx"],
"docs": ["sphinx", "ipython"],
}

Expand Down

0 comments on commit e29c3d6

Please sign in to comment.