Skip to content

Commit e488c6e

Browse files
authored
Replace Black with Ruff formatter (#20445)
1 parent c052cea commit e488c6e

File tree

74 files changed

+97
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+97
-179
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
"source.organizeImports": true
1111
},
1212
"[python]": {
13-
"editor.defaultFormatter": "ms-python.black-formatter"
13+
"editor.defaultFormatter": "charliermarsh.ruff"
1414
},
1515
"editor.rulers": [
1616
80
1717
]
1818
},
1919
"extensions": [
2020
"charliermarsh.ruff",
21-
"ms-python.python",
22-
"ms-python.black-formatter"
21+
"ms-python.python"
2322
]
2423
}
2524
},

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ section of the README.
109109

110110
## Code style
111111

112-
Keras uses [Black](https://black.readthedocs.io/en/stable/) and
113-
[Ruff](https://docs.astral.sh/ruff/) to format the code. Please refer to
112+
Keras uses [Ruff](https://docs.astral.sh/ruff/) to format the code. Please refer to
114113
[requirements-common.txt](https://github.com/keras-team/keras/blob/master/requirements-common.txt)
115114
for the required versions. Run the following command **at the root directory of
116115
the repo** to format your code.

examples/demo_custom_layer_backend_agnostic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ def __init__(self, rate, name=None):
4747

4848
def call(self, inputs):
4949
# Use `keras.random` for random ops.
50-
return keras.random.dropout(
51-
inputs, self.rate, seed=self.seed_generator
52-
)
50+
return keras.random.dropout(inputs, self.rate, seed=self.seed_generator)
5351

5452

5553
class MyModel(Model):

examples/demo_jax_distributed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
BATCH_SIZE = 192
2929

30-
(x_train, train_labels), (
31-
x_eval,
32-
eval_labels,
30+
(
31+
(x_train, train_labels),
32+
(x_eval, eval_labels),
3333
) = keras.datasets.mnist.load_data()
3434
x_train = np.expand_dims(x_train, axis=-1).astype(
3535
np.float32

guides/making_new_layers_and_models_via_subclassing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def __init__(
643643
intermediate_dim=64,
644644
latent_dim=32,
645645
name="autoencoder",
646-
**kwargs
646+
**kwargs,
647647
):
648648
super().__init__(name=name, **kwargs)
649649
self.original_dim = original_dim

integration_tests/dataset_tests/boston_housing_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
class BostonHousingTest(testing.TestCase):
6-
76
def test_load_data(self):
87
(x_train, y_train), (x_test, y_test) = boston_housing.load_data()
98
self.assertEqual(x_train.shape[1], 13)

integration_tests/dataset_tests/california_housing_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
class CaliforniaHousingTest(testing.TestCase):
6-
76
def test_load_data_large(self):
87
(x_train, y_train), (x_test, y_test) = california_housing.load_data(
98
version="large"

integration_tests/model_visualization_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def get_edge_dict(dot):
4141

4242

4343
class ModelVisualizationTest(testing.TestCase):
44-
4544
def test_plot_sequential_model(self):
4645
model = keras.Sequential(
4746
[

keras/src/backend/common/masking_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class MaskingTest(testing.TestCase):
9-
109
def test_mask_on_eager_tensor(self):
1110
x = ops.zeros((2, 3))
1211
self.assertIsNone(get_keras_mask(x))
@@ -25,7 +24,6 @@ def test_mask_on_eager_tensor(self):
2524
self.assertIsNone(get_keras_mask(x))
2625

2726
def test_mask_on_tracer_tensor(self):
28-
2927
def fn(x):
3028
self.assertIsNone(get_keras_mask(x))
3129

keras/src/backend/common/symbolic_scope_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
class TestSymbolicScope(testing.TestCase):
1010
def test_basic_flow(self):
11-
1211
# Define a function that behaves differently according to
1312
# `in_symbolic_scope`.
1413
def compute_loss(y, y_pred):

0 commit comments

Comments
 (0)