Skip to content

Commit

Permalink
Merge pull request #286 from timtroendle/feature-consistent-formatting
Browse files Browse the repository at this point in the history
Add Ruff linter and formatter
  • Loading branch information
timtroendle authored Mar 15, 2024
2 parents daed991 + f9e9bc7 commit c7e0300
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://pre-commit.com for more information
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
# See https://pre-commit.com/hooks
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
36 changes: 36 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
line-length = 88
preview = true # required to activate many pycodestyle errors and warnings as of 2024-03-13
builtins = ["snakemake"]

[format]
quote-style = "double"
indent-style = "space"
docstring-code-format = false
line-ending = "auto"

[lint]
select = [
# pycodestyle errors
"E",
# pycodestyle warnings
"W",
# Pyflakes
"F",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
ignore = [
# here and below, rules are redundant with formatter, see
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"E501",
"W191",
"E111",
"E114",
"E117",
]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Added (workflow)

* **ADD** Ruff as our default linter and formatter (#285).
* **ADD** DAG rule that generates a visualisation of Snakemake's directed acyclic graph (#208).
* **ADD** IPython debugger to all conda environments to ease debugging (#254).
* **ADD** a default Snakemake profile to run on local machines in addition to the existing profile for Euler (#211).
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ If you have found a bug in Euro-Calliope or you want to propose a new feature, p

We welcome changes that you provide as [a pull request](https://github.com/calliope-project/euro-calliope/pulls).

If you consider doing that, you need to know our branching model -- that is, which branches exist and what meaning they have.
If you consider doing that, you need to know two things: our code guidelines and our branching model.
Our code guidelines are implemented through automatic linting (code analysis) and formatting. For both, we employ the tool [Ruff](https://docs.astral.sh/ruff/). It is open-source and available as a [plug-in to many IDEs](https://docs.astral.sh/ruff/integrations/). All you need is to install the plug-in for your IDE and then you should see linting problems and you will be able to format the code automatically based on our guidelines. If you want more, you can use a [Git pre-commit-hook](https://pre-commit.com) but that step is optional.

Next, let's talk about our branching model -- that is, which branches exist and what meaning they have.
Do not worry, it is easy. Our branching model is a simplified version of _git-flow_. We are giving you a summary here that is likely sufficient for you.
If you want more information, read the [blog entry](https://nvie.com/posts/a-successful-git-branching-model/) introducing git-flow.

Expand Down

0 comments on commit c7e0300

Please sign in to comment.