Skip to content

Commit f0ec89c

Browse files
authored
Switch from black, isort, flake8 to ruff (#9)
For consistency with Keras.
1 parent 05712aa commit f0ec89c

File tree

6 files changed

+31
-26
lines changed

6 files changed

+31
-26
lines changed

examples/basic_ranking.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
"""
2828

2929
import keras
30-
31-
# Needed for the dataset
32-
import tensorflow as tf
30+
import tensorflow as tf # Needed for the dataset
3331
import tensorflow_datasets as tfds
3432

3533
"""
@@ -113,7 +111,6 @@ def preprocess_rating(x):
113111

114112

115113
class RankingModel(keras.Model):
116-
117114
def __init__(
118115
self,
119116
num_users,

examples/basic_retrieval.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@
6262
"""
6363

6464
import keras
65-
66-
# Needed for the dataset
67-
import tensorflow as tf
65+
import tensorflow as tf # Needed for the dataset
6866
import tensorflow_datasets as tfds
6967

7068
import keras_rs

pyproject.toml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
[tool.black]
1+
[tool.ruff]
22
line-length = 80
33

4-
[tool.isort]
5-
profile = "black"
6-
force_single_line = "True"
7-
single_line_exclusions = ["typing"]
8-
known_first_party = ["keras_rs"]
9-
default_section = "THIRDPARTY"
10-
line_length = 80
4+
[tool.ruff.lint]
5+
select = [
6+
"E", # pycodestyle error
7+
"F", # Pyflakes
8+
"I", # isort
9+
]
10+
11+
[tool.ruff.lint.per-file-ignores]
12+
"**/__init__.py" = ["F401"] # imported but unused
13+
14+
[tool.ruff.lint.isort]
15+
force-single-line = true
16+
single-line-exclusions = ["typing"]
17+
known-first-party = ["keras_rs"]
1118

1219
[tool.mypy]
1320
strict = "True"

requirements-common.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
namex>=0.0.8
33

44
# formatting and linting
5-
black>=22
6-
flake8
7-
isort
85
mypy
6+
ruff
97

108
# testing
119
absl-py

shell/format.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/bin/bash
2-
set -Eeuo pipefail
2+
set -Euo pipefail
33

44
base_dir=$(dirname $(dirname $0))
55
targets="${base_dir}"
66

7-
isort --sp "${base_dir}/pyproject.toml" ${targets}
8-
black --config "${base_dir}/pyproject.toml" ${targets}
9-
flake8 --config "${base_dir}/setup.cfg" ${targets}
7+
ruff check --config "${base_dir}/pyproject.toml" --fix ${targets}
8+
ruff format --config "${base_dir}/pyproject.toml" ${targets}
109
mypy --config-file "${base_dir}/pyproject.toml" ${targets}

shell/lint.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
2-
set -Eeuo pipefail
2+
set -Euo pipefail
33

44
base_dir=$(dirname $(dirname $0))
55
targets="${base_dir}"
66

7-
isort --sp "${base_dir}/pyproject.toml" --check ${targets}
8-
black --config "${base_dir}/pyproject.toml" --check ${targets}
9-
flake8 --config "${base_dir}/setup.cfg" ${targets}
7+
ruff check --config "${base_dir}/pyproject.toml" ${targets}
8+
exitcode=$?
9+
10+
ruff format --check --config "${base_dir}/pyproject.toml" ${targets}
11+
exitcode=$(($exitcode + $?))
12+
1013
mypy --config-file "${base_dir}/pyproject.toml" ${targets}
14+
exitcode=$(($exitcode + $?))
15+
16+
exit $exitcode

0 commit comments

Comments
 (0)