From eed2e7af65b8fbb0575c3080ce57569531bc9838 Mon Sep 17 00:00:00 2001 From: Haifeng Jin <5476582+haifeng-jin@users.noreply.github.com> Date: Sun, 14 May 2023 18:41:50 +0000 Subject: [PATCH] fix lint (#168) Co-authored-by: Haifeng Jin --- keras_core/layers/layer.py | 13 +++++++++---- keras_core/trainers/epoch_iterator.py | 4 ++-- pip_build.py | 3 ++- setup.cfg | 14 -------------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/keras_core/layers/layer.py b/keras_core/layers/layer.py index 4db94dd92fd..ac041be21db 100644 --- a/keras_core/layers/layer.py +++ b/keras_core/layers/layer.py @@ -472,7 +472,8 @@ def stateless_call( Args: trainable_variables: List of trainable variables of the model. - non_trainable_variables: List of non-trainable variables of the model. + non_trainable_variables: List of non-trainable variables of the + model. *args: Positional argumets to be passed to `call()`. return_losses: If `True`, `stateless_call()` will return the list of losses created during `call()` as part of its return values. @@ -504,7 +505,9 @@ def stateless_call( ) # Attach the updated state to the model # (until you do this, the model is still in its pre-call state). - for ref_var, value in zip(model.non_trainable_variables, non_trainable_variables): + for ref_var, value in zip( + model.non_trainable_variables, non_trainable_variables + ): ref_var.assign(value) ``` """ @@ -597,7 +600,8 @@ def compute_output_spec(self, *args, **kwargs): and isinstance(output_shape[0], (int, type(None))) ): return KerasTensor(output_shape, dtype=self.compute_dtype) - # Case: nested. Could be a tuple/list of shapes, or a dict of shapes. + # Case: nested. Could be a tuple/list of shapes, or a dict of + # shapes. if isinstance(output_shape, list): return [ KerasTensor(s, dtype=self.compute_dtype) @@ -770,7 +774,8 @@ def _maybe_build(self, call_spec): "In a layer with multiple tensor arguments " "in call(), the build() method should accept " "corresponding `*_shape` arguments, e.g. " - "if the call signature is `def call(self, x1, x2)` " + "if the call signature is " + "`def call(self, x1, x2)` " "then the build signature should be " "`def build(self, x1_shape, x2_shape)`. " "Keras will not build this layer automatically " diff --git a/keras_core/trainers/epoch_iterator.py b/keras_core/trainers/epoch_iterator.py index 52e66b4bcc3..397e3cff7a9 100644 --- a/keras_core/trainers/epoch_iterator.py +++ b/keras_core/trainers/epoch_iterator.py @@ -115,8 +115,8 @@ def __init__( ) if class_weight is not None: raise ValueError( - "Argument `class_weight` is not supported for Python generator " - f"inputs. Received: class_weight={class_weight}" + "Argument `class_weight` is not supported for Python " + f"generator inputs. Received: class_weight={class_weight}" ) if shuffle: raise ValueError( diff --git a/pip_build.py b/pip_build.py index 6ef04e3daa0..d22f80c67e5 100644 --- a/pip_build.py +++ b/pip_build.py @@ -40,7 +40,8 @@ def build(): whl_path = None try: - # Copy sources (`keras_core/` directory and setup files) to build directory + # Copy sources (`keras_core/` directory and setup files) to build + # directory root_path = pathlib.Path(__file__).parent.resolve() os.chdir(root_path) os.mkdir(build_directory) diff --git a/setup.cfg b/setup.cfg index 354135a19ed..a88b3924f5b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,18 +48,4 @@ per-file-ignores = # import not used **/__init__.py:F401 **/random.py:F401 - # TODO: remove the following files when long lines are reformatted. - keras_core/trainers/trainer.py:E501 - keras_core/trainers/epoch_iterator.py:E501 - keras_core/trainers/data_adapters/array_data_adapter.py:E501 - keras_core/trainers/compile_utils.py:E501 - keras_core/saving/object_registration.py:E501 - keras_core/regularizers/regularizers.py:E501 - keras_core/optimizers/optimizer.py:E501 - keras_core/operations/function.py:E501 - keras_core/models/sequential.py:E501 - keras_core/models/functional.py:E501 - keras_core/layers/layer.py:E501 - keras_core/initializers/random_initializers.py:E501 - keras_core/saving/saving_lib_test.py:E501 max-line-length = 80