The following issues were found

keras/legacy_tf_layers/core.py
34 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 15 Column: 1

              # See the License for the specific language governing permissions and
# limitations under the License.
# =============================================================================
# pylint: disable=g-classes-have-attributes
"""Contains the core layers: Dense, Dropout.

Also contains their functional aliases.
"""
from __future__ import absolute_import

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 24 Column: 1

              from __future__ import division
from __future__ import print_function

import tensorflow.compat.v2 as tf

import warnings

from keras import layers as keras_layers
from keras.legacy_tf_layers import base

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 30 Column: 1

              
from keras import layers as keras_layers
from keras.legacy_tf_layers import base
from tensorflow.python.util.tf_export import keras_export
from tensorflow.python.util.tf_export import tf_export


@keras_export(v1=['keras.__internal__.legacy.layers.Dense'])
@tf_export(v1=['layers.Dense'])

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 31 Column: 1

              from keras import layers as keras_layers
from keras.legacy_tf_layers import base
from tensorflow.python.util.tf_export import keras_export
from tensorflow.python.util.tf_export import tf_export


@keras_export(v1=['keras.__internal__.legacy.layers.Dense'])
@tf_export(v1=['layers.Dense'])
class Dense(keras_layers.Dense, base.Layer):

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 450 Column: 3

                ```
  @end_compatibility
  """
  pass


@keras_export(v1=['keras.__internal__.legacy.layers.flatten'])
@tf_export(v1=['layers.flatten'])
def flatten(inputs, name=None, data_format='channels_last'):

            

Reported by Pylint.

standard import "import warnings" should be placed before "import tensorflow.compat.v2 as tf"
Error

Line: 26 Column: 1

              
import tensorflow.compat.v2 as tf

import warnings

from keras import layers as keras_layers
from keras.legacy_tf_layers import base
from tensorflow.python.util.tf_export import keras_export
from tensorflow.python.util.tf_export import tf_export

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

              @keras_export(v1=['keras.__internal__.legacy.layers.Dense'])
@tf_export(v1=['layers.Dense'])
class Dense(keras_layers.Dense, base.Layer):
  """Densely-connected layer class.

  This layer implements the operation:
  `outputs = activation(inputs * kernel + bias)`
  Where `activation` is the activation function passed as the `activation`
  argument (if not `None`), `kernel` is a weights matrix created by the layer,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 116 Column: 1

                @end_compatibility
  """

  def __init__(self, units,
               activation=None,
               use_bias=True,
               kernel_initializer=None,
               bias_initializer=tf.compat.v1.zeros_initializer(),
               kernel_regularizer=None,

            

Reported by Pylint.

Too many arguments (13/5)
Error

Line: 116 Column: 3

                @end_compatibility
  """

  def __init__(self, units,
               activation=None,
               use_bias=True,
               kernel_initializer=None,
               bias_initializer=tf.compat.v1.zeros_initializer(),
               kernel_regularizer=None,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 129 Column: 1

                             trainable=True,
               name=None,
               **kwargs):
    super(Dense, self).__init__(units=units,
                                activation=activation,
                                use_bias=use_bias,
                                kernel_initializer=kernel_initializer,
                                bias_initializer=bias_initializer,
                                kernel_regularizer=kernel_regularizer,

            

Reported by Pylint.

keras/layers/preprocessing/benchmarks/category_vocab_list_indicator_varlen_benchmark.py
34 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark for KPL implementation of vocabulary columns + indicator from lists with varying-length inputs."""

import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 19 Column: 1

              
import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm


            

Reported by Pylint.

Unable to import 'tensorflow.python.eager.def_function'
Error

Line: 20 Column: 1

              import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 21 Column: 1

              
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 22 Column: 1

              import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()


            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing.benchmarks'
Error

Line: 23 Column: 1

              from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

NUM_REPEATS = 10

            

Reported by Pylint.

Line too long (111/100)
Error

Line: 15 Column: 1

              # See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Benchmark for KPL implementation of vocabulary columns + indicator from lists with varying-length inputs."""

import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

              

def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  vocab_size = 32768
  vocab = fc_bm.create_vocabulary(vocab_size)
  data = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  vocab_size = 32768
  vocab = fc_bm.create_vocabulary(vocab_size)
  data = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)

  # Keras implementation

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

                """Benchmark a variable-length embedding."""
  # Data and constants.
  vocab_size = 32768
  vocab = fc_bm.create_vocabulary(vocab_size)
  data = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)

  # Keras implementation
  model = keras.Sequential()

            

Reported by Pylint.

keras/layers/preprocessing/benchmarks/weighted_embedding_varlen_benchmark.py
34 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark for KPL implementation of weighted embedding column with varying-length inputs."""

import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm


            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 19 Column: 1

              
import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

            

Reported by Pylint.

Unable to import 'tensorflow.python.eager.def_function'
Error

Line: 20 Column: 1

              import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()


            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing.benchmarks'
Error

Line: 21 Column: 1

              
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

NUM_REPEATS = 10

            

Reported by Pylint.

Too many local variables (17/15)
Error

Line: 31 Column: 1

              

### KPL AND FC IMPLEMENTATION BENCHMARKS ###
def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  embedding_size = 32768
  data = fc_bm.create_data(
      max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              
### KPL AND FC IMPLEMENTATION BENCHMARKS ###
def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  embedding_size = 32768
  data = fc_bm.create_data(
      max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
  weight = tf.ones_like(data, dtype=tf.float32)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 34 Column: 1

              def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  embedding_size = 32768
  data = fc_bm.create_data(
      max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
  weight = tf.ones_like(data, dtype=tf.float32)

  # Keras implementation

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

                """Benchmark a variable-length embedding."""
  # Data and constants.
  embedding_size = 32768
  data = fc_bm.create_data(
      max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
  weight = tf.ones_like(data, dtype=tf.float32)

  # Keras implementation
  data_input = keras.Input(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 37 Column: 1

                embedding_size = 32768
  data = fc_bm.create_data(
      max_length, batch_size * NUM_REPEATS, embedding_size - 1, dtype=int)
  weight = tf.ones_like(data, dtype=tf.float32)

  # Keras implementation
  data_input = keras.Input(
      shape=(None,), ragged=True, name="data", dtype=tf.int64)
  weight_input = keras.Input(

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 40 Column: 1

                weight = tf.ones_like(data, dtype=tf.float32)

  # Keras implementation
  data_input = keras.Input(
      shape=(None,), ragged=True, name="data", dtype=tf.int64)
  weight_input = keras.Input(
      shape=(None,), ragged=True, name="weight", dtype=tf.float32)
  embedded_data = keras.layers.Embedding(embedding_size, 256)(data_input)
  weighted_embedding = tf.multiply(

            

Reported by Pylint.

keras/layers/preprocessing/benchmarks/category_vocab_list_indicator_dense_benchmark.py
34 issues
Unable to import 'tensorflow'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Benchmark for KPL implementation of vocabulary columns + indicator from lists with dense inputs."""

import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup

            

Reported by Pylint.

Unable to import 'keras'
Error

Line: 19 Column: 1

              
import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm


            

Reported by Pylint.

Unable to import 'tensorflow.python.eager.def_function'
Error

Line: 20 Column: 1

              import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 21 Column: 1

              
import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing'
Error

Line: 22 Column: 1

              import keras
from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()


            

Reported by Pylint.

Unable to import 'keras.layers.preprocessing.benchmarks'
Error

Line: 23 Column: 1

              from tensorflow.python.eager.def_function import function as tf_function
from keras.layers.preprocessing import category_encoding
from keras.layers.preprocessing import string_lookup
from keras.layers.preprocessing.benchmarks import feature_column_benchmark as fc_bm

# This is required as of 3/2021 because otherwise we drop into graph mode.
tf.compat.v1.enable_v2_behavior()

NUM_REPEATS = 10

            

Reported by Pylint.

Line too long (102/100)
Error

Line: 15 Column: 1

              # See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Benchmark for KPL implementation of vocabulary columns + indicator from lists with dense inputs."""

import tensorflow as tf

import keras
from tensorflow.python.eager.def_function import function as tf_function

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

              

def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  vocab_size = 32768
  vocab = fc_bm.create_vocabulary(vocab_size)
  data = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 35 Column: 1

              def embedding_varlen(batch_size, max_length):
  """Benchmark a variable-length embedding."""
  # Data and constants.
  vocab_size = 32768
  vocab = fc_bm.create_vocabulary(vocab_size)
  data = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)

  # Keras implementation

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 36 Column: 1

                """Benchmark a variable-length embedding."""
  # Data and constants.
  vocab_size = 32768
  vocab = fc_bm.create_vocabulary(vocab_size)
  data = fc_bm.create_string_data(
      max_length, batch_size * NUM_REPEATS, vocab, pct_oov=0.15)

  # Keras implementation
  model = keras.Sequential()

            

Reported by Pylint.

keras/saving/saved_model/model_serialization.py
33 issues
Unable to import 'keras.saving'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Classes and functions implementing to Model SavedModel serialization."""

from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import layer_serialization
from keras.saving.saved_model import save_impl



            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 18 Column: 1

              """Classes and functions implementing to Model SavedModel serialization."""

from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import layer_serialization
from keras.saving.saved_model import save_impl


class ModelSavedModelSaver(layer_serialization.LayerSavedModelSaver):

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 19 Column: 1

              
from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import layer_serialization
from keras.saving.saved_model import save_impl


class ModelSavedModelSaver(layer_serialization.LayerSavedModelSaver):
  """Model SavedModel serialization."""

            

Reported by Pylint.

Unable to import 'keras.saving.saved_model'
Error

Line: 20 Column: 1

              from keras.saving import saving_utils
from keras.saving.saved_model import constants
from keras.saving.saved_model import layer_serialization
from keras.saving.saved_model import save_impl


class ModelSavedModelSaver(layer_serialization.LayerSavedModelSaver):
  """Model SavedModel serialization."""


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 23 Column: 1

              from keras.saving.saved_model import save_impl


class ModelSavedModelSaver(layer_serialization.LayerSavedModelSaver):
  """Model SavedModel serialization."""

  @property
  def object_identifier(self):
    return constants.MODEL_IDENTIFIER

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 24 Column: 1

              

class ModelSavedModelSaver(layer_serialization.LayerSavedModelSaver):
  """Model SavedModel serialization."""

  @property
  def object_identifier(self):
    return constants.MODEL_IDENTIFIER


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 26 Column: 1

              class ModelSavedModelSaver(layer_serialization.LayerSavedModelSaver):
  """Model SavedModel serialization."""

  @property
  def object_identifier(self):
    return constants.MODEL_IDENTIFIER

  def _python_properties_internal(self):
    metadata = super(ModelSavedModelSaver, self)._python_properties_internal()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 3

                """Model SavedModel serialization."""

  @property
  def object_identifier(self):
    return constants.MODEL_IDENTIFIER

  def _python_properties_internal(self):
    metadata = super(ModelSavedModelSaver, self)._python_properties_internal()
    # Network stateful property is dependent on the child layers.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

                """Model SavedModel serialization."""

  @property
  def object_identifier(self):
    return constants.MODEL_IDENTIFIER

  def _python_properties_internal(self):
    metadata = super(ModelSavedModelSaver, self)._python_properties_internal()
    # Network stateful property is dependent on the child layers.

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

              
  @property
  def object_identifier(self):
    return constants.MODEL_IDENTIFIER

  def _python_properties_internal(self):
    metadata = super(ModelSavedModelSaver, self)._python_properties_internal()
    # Network stateful property is dependent on the child layers.
    metadata.pop('stateful')

            

Reported by Pylint.

keras/layers/preprocessing/integer_lookup.py
33 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Keras string lookup preprocessing layer."""

# pylint: disable=g-classes-have-attributes

from keras.engine import base_preprocessing_layer
from keras.layers.preprocessing import index_lookup
import numpy as np
import tensorflow.compat.v2 as tf

            

Reported by Pylint.

Unable to import 'tensorflow.compat.v2'
Error

Line: 22 Column: 1

              from keras.engine import base_preprocessing_layer
from keras.layers.preprocessing import index_lookup
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export


@keras_export(

            

Reported by Pylint.

Unable to import 'tensorflow.python.platform'
Error

Line: 23 Column: 1

              from keras.layers.preprocessing import index_lookup
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export


@keras_export(
    "keras.layers.IntegerLookup",

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 24 Column: 1

              import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util.tf_export import keras_export


@keras_export(
    "keras.layers.IntegerLookup",
    "keras.layers.experimental.preprocessing.IntegerLookup",

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

                  "keras.layers.experimental.preprocessing.IntegerLookup",
    v1=[])
class IntegerLookup(index_lookup.IndexLookup):
  """Reindex integer inputs to be in a contiguous range, via a dict lookup.

  This layer maps a set of arbitrary integer input tokens into indexed
  integer output via a table-based vocabulary lookup. The layer's output indices
  will be contiguously arranged up to the maximum vocab size, even if the input
  tokens are non-continguous or unbounded. The layer supports multiple options

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 297 Column: 1

                either directly or via `adapt()` before calling `get_vocabulary()`.
  """

  def __init__(self,
               max_tokens=None,
               num_oov_indices=1,
               mask_token=None,
               oov_token=-1,
               vocabulary=None,

            

Reported by Pylint.

Too many arguments (10/5)
Error

Line: 297 Column: 3

                either directly or via `adapt()` before calling `get_vocabulary()`.
  """

  def __init__(self,
               max_tokens=None,
               num_oov_indices=1,
               mask_token=None,
               oov_token=-1,
               vocabulary=None,

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 308 Column: 1

                             sparse=False,
               pad_to_max_tokens=False,
               **kwargs):
    allowed_dtypes = [tf.int64]

    # Support deprecated args for this layer.
    if "max_values" in kwargs:
      logging.log_first_n(logging.WARN,
                          "max_values is deprecated, use max_tokens instead.",

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 311 Column: 1

                  allowed_dtypes = [tf.int64]

    # Support deprecated args for this layer.
    if "max_values" in kwargs:
      logging.log_first_n(logging.WARN,
                          "max_values is deprecated, use max_tokens instead.",
                          1)
      max_tokens = kwargs["max_values"]
      del kwargs["max_values"]

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 312 Column: 1

              
    # Support deprecated args for this layer.
    if "max_values" in kwargs:
      logging.log_first_n(logging.WARN,
                          "max_values is deprecated, use max_tokens instead.",
                          1)
      max_tokens = kwargs["max_values"]
      del kwargs["max_values"]
    if "mask_value" in kwargs:

            

Reported by Pylint.

keras/integration_test/tf_trt_test.py
33 issues
Unable to import 'absl'
Error

Line: 19 Column: 1

              import os
import tempfile

from absl import flags

import tensorflow as tf
import tensorflow_text as tf_text



            

Reported by Pylint.

Unable to import 'tensorflow'
Error

Line: 21 Column: 1

              
from absl import flags

import tensorflow as tf
import tensorflow_text as tf_text


class ConvertResource(tf.test.TestCase):


            

Reported by Pylint.

Unable to import 'tensorflow_text'
Error

Line: 22 Column: 1

              from absl import flags

import tensorflow as tf
import tensorflow_text as tf_text


class ConvertResource(tf.test.TestCase):

  def testConvertResource(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software

            

Reported by Pylint.

Missing class docstring
Error

Line: 25 Column: 1

              import tensorflow_text as tf_text


class ConvertResource(tf.test.TestCase):

  def testConvertResource(self):
    """Test general resource inputs don't crash the converter."""
    if not tf.test.is_built_with_cuda():
      self.skipTest('test is only applicable with CUDA')

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 25 Column: 1

              import tensorflow_text as tf_text


class ConvertResource(tf.test.TestCase):

  def testConvertResource(self):
    """Test general resource inputs don't crash the converter."""
    if not tf.test.is_built_with_cuda():
      self.skipTest('test is only applicable with CUDA')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 27 Column: 1

              
class ConvertResource(tf.test.TestCase):

  def testConvertResource(self):
    """Test general resource inputs don't crash the converter."""
    if not tf.test.is_built_with_cuda():
      self.skipTest('test is only applicable with CUDA')

    class TokenizeLayer(tf.keras.layers.Layer):

            

Reported by Pylint.

Method name "testConvertResource" doesn't conform to snake_case naming style
Error

Line: 27 Column: 3

              
class ConvertResource(tf.test.TestCase):

  def testConvertResource(self):
    """Test general resource inputs don't crash the converter."""
    if not tf.test.is_built_with_cuda():
      self.skipTest('test is only applicable with CUDA')

    class TokenizeLayer(tf.keras.layers.Layer):

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 28 Column: 1

              class ConvertResource(tf.test.TestCase):

  def testConvertResource(self):
    """Test general resource inputs don't crash the converter."""
    if not tf.test.is_built_with_cuda():
      self.skipTest('test is only applicable with CUDA')

    class TokenizeLayer(tf.keras.layers.Layer):


            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 29 Column: 1

              
  def testConvertResource(self):
    """Test general resource inputs don't crash the converter."""
    if not tf.test.is_built_with_cuda():
      self.skipTest('test is only applicable with CUDA')

    class TokenizeLayer(tf.keras.layers.Layer):

      def __init__(self, vocab_file):

            

Reported by Pylint.

keras/saving/save.py
33 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Keras model saving code."""

import tensorflow.compat.v2 as tf
from keras.saving import hdf5_format
from keras.saving import saving_utils
from keras.saving.saved_model import load as saved_model_load
from keras.saving.saved_model import load_context
from keras.saving.saved_model import save as saved_model_save

            

Reported by Pylint.

Unable to import 'tensorflow.python.util.tf_export'
Error

Line: 26 Column: 1

              from keras.utils import generic_utils
from keras.utils import traceback_utils
from keras.utils.io_utils import path_to_string
from tensorflow.python.util.tf_export import keras_export

# pylint: disable=g-import-not-at-top
try:
  import h5py
except ImportError:

            

Reported by Pylint.

Bad option value 'g-import-not-at-top'
Error

Line: 28 Column: 1

              from keras.utils.io_utils import path_to_string
from tensorflow.python.util.tf_export import keras_export

# pylint: disable=g-import-not-at-top
try:
  import h5py
except ImportError:
  h5py = None
# pylint: enable=g-import-not-at-top

            

Reported by Pylint.

Bad option value 'g-import-not-at-top'
Error

Line: 33 Column: 1

                import h5py
except ImportError:
  h5py = None
# pylint: enable=g-import-not-at-top


@keras_export('keras.models.save_model')
@traceback_utils.filter_traceback
def save_model(model,

            

Reported by Pylint.

Bad option value 'g-import-not-at-top'
Error

Line: 122 Column: 1

                    ImportError: If save format is hdf5, and h5py is not available.
  """
  # pylint: enable=line-too-long
  from keras.engine import sequential  # pylint: disable=g-import-not-at-top

  default_format = 'tf' if tf.__internal__.tf2.enabled() else 'h5'
  save_format = save_format or default_format

  filepath = path_to_string(filepath)

            

Reported by Pylint.

TODO(b/130258301): add utility method for detecting model type.
Error

Line: 137 Column: 3

                if (save_format == 'h5' or
      (h5py is not None and isinstance(filepath, h5py.File)) or
      saving_utils.is_hdf5_filepath(filepath)):
    # TODO(b/130258301): add utility method for detecting model type.
    if (not model._is_graph_network and  # pylint:disable=protected-access
        not isinstance(model, sequential.Sequential)):
      raise NotImplementedError(
          'Saving the model to HDF5 format requires the model to be a '
          'Functional model or a Sequential model. It does not work for '

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              
# pylint: disable=g-import-not-at-top
try:
  import h5py
except ImportError:
  h5py = None
# pylint: enable=g-import-not-at-top



            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

              try:
  import h5py
except ImportError:
  h5py = None
# pylint: enable=g-import-not-at-top


@keras_export('keras.models.save_model')
@traceback_utils.filter_traceback

            

Reported by Pylint.

Too many arguments (8/5)
Error

Line: 38 Column: 1

              
@keras_export('keras.models.save_model')
@traceback_utils.filter_traceback
def save_model(model,
               filepath,
               overwrite=True,
               include_optimizer=True,
               save_format=None,
               signatures=None,

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 47 Column: 1

                             options=None,
               save_traces=True):
  # pylint: disable=line-too-long
  """Saves a model as a TensorFlow SavedModel or HDF5 file.

  See the [Serialization and Saving guide](https://keras.io/guides/serialization_and_saving/)
  for details.

  Usage:

            

Reported by Pylint.

keras/layers/preprocessing/normalization_tpu_test.py
32 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for keras.layers.preprocessing.normalization."""

import tensorflow.compat.v2 as tf

from absl.testing import parameterized

import numpy as np


            

Reported by Pylint.

Unable to import 'absl.testing'
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

from absl.testing import parameterized

import numpy as np

import keras
from keras import keras_parameterized

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 31 Column: 1

              

def _get_layer_computation_test_cases():
  test_cases = ({
      "adapt_data": np.array([[1.], [2.], [3.], [4.], [5.]], dtype=np.float32),
      "axis": -1,
      "test_data": np.array([[1.], [2.], [3.]], np.float32),
      "expected": np.array([[-1.414214], [-.707107], [0]], np.float32),
      "testcase_name": "2d_single_element"

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 82 Column: 1

                        "3d_multiple_axis"
  })

  crossed_test_cases = []
  # Cross above test cases with use_dataset in (True, False)
  for use_dataset in (True, False):
    for case in test_cases:
      case = case.copy()
      if use_dataset:

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 84 Column: 1

              
  crossed_test_cases = []
  # Cross above test cases with use_dataset in (True, False)
  for use_dataset in (True, False):
    for case in test_cases:
      case = case.copy()
      if use_dataset:
        case["testcase_name"] = case["testcase_name"] + "_with_dataset"
      case["use_dataset"] = use_dataset

            

Reported by Pylint.

Bad indentation. Found 4 spaces, expected 8
Style

Line: 85 Column: 1

                crossed_test_cases = []
  # Cross above test cases with use_dataset in (True, False)
  for use_dataset in (True, False):
    for case in test_cases:
      case = case.copy()
      if use_dataset:
        case["testcase_name"] = case["testcase_name"] + "_with_dataset"
      case["use_dataset"] = use_dataset
      crossed_test_cases.append(case)

            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 86 Column: 1

                # Cross above test cases with use_dataset in (True, False)
  for use_dataset in (True, False):
    for case in test_cases:
      case = case.copy()
      if use_dataset:
        case["testcase_name"] = case["testcase_name"] + "_with_dataset"
      case["use_dataset"] = use_dataset
      crossed_test_cases.append(case)


            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 87 Column: 1

                for use_dataset in (True, False):
    for case in test_cases:
      case = case.copy()
      if use_dataset:
        case["testcase_name"] = case["testcase_name"] + "_with_dataset"
      case["use_dataset"] = use_dataset
      crossed_test_cases.append(case)

  return crossed_test_cases

            

Reported by Pylint.

Bad indentation. Found 8 spaces, expected 16
Style

Line: 88 Column: 1

                  for case in test_cases:
      case = case.copy()
      if use_dataset:
        case["testcase_name"] = case["testcase_name"] + "_with_dataset"
      case["use_dataset"] = use_dataset
      crossed_test_cases.append(case)

  return crossed_test_cases


            

Reported by Pylint.

Bad indentation. Found 6 spaces, expected 12
Style

Line: 89 Column: 1

                    case = case.copy()
      if use_dataset:
        case["testcase_name"] = case["testcase_name"] + "_with_dataset"
      case["use_dataset"] = use_dataset
      crossed_test_cases.append(case)

  return crossed_test_cases



            

Reported by Pylint.

keras/utils/io_utils_test.py
32 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Tests for io_utils."""

import tensorflow.compat.v2 as tf

import builtins
from pathlib import Path

from keras import keras_parameterized

            

Reported by Pylint.

Probable insecure usage of temp file/directory.
Security

Line: 31
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

                def test_ask_to_proceed_with_overwrite(self):
    with tf.compat.v1.test.mock.patch.object(builtins, 'input') as mock_log:
      mock_log.return_value = 'y'
      self.assertTrue(io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.return_value = 'n'
      self.assertFalse(
          io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))


            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 35
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

              
      mock_log.return_value = 'n'
      self.assertFalse(
          io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.side_effect = ['m', 'y']
      self.assertTrue(io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.side_effect = ['m', 'n']

            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 38
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

                        io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.side_effect = ['m', 'y']
      self.assertTrue(io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.side_effect = ['m', 'n']
      self.assertFalse(
          io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))


            

Reported by Bandit.

Probable insecure usage of temp file/directory.
Security

Line: 42
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html

              
      mock_log.side_effect = ['m', 'n']
      self.assertFalse(
          io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

  def test_path_to_string(self):

    class PathLikeDummy:


            

Reported by Bandit.

standard import "import builtins" should be placed before "import tensorflow.compat.v2 as tf"
Error

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import builtins
from pathlib import Path

from keras import keras_parameterized
from keras.utils import io_utils


            

Reported by Pylint.

standard import "from pathlib import Path" should be placed before "import tensorflow.compat.v2 as tf"
Error

Line: 20 Column: 1

              import tensorflow.compat.v2 as tf

import builtins
from pathlib import Path

from keras import keras_parameterized
from keras.utils import io_utils



            

Reported by Pylint.

Missing class docstring
Error

Line: 26 Column: 1

              from keras.utils import io_utils


class TestIOUtils(keras_parameterized.TestCase):

  def test_ask_to_proceed_with_overwrite(self):
    with tf.compat.v1.test.mock.patch.object(builtins, 'input') as mock_log:
      mock_log.return_value = 'y'
      self.assertTrue(io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 28 Column: 1

              
class TestIOUtils(keras_parameterized.TestCase):

  def test_ask_to_proceed_with_overwrite(self):
    with tf.compat.v1.test.mock.patch.object(builtins, 'input') as mock_log:
      mock_log.return_value = 'y'
      self.assertTrue(io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.return_value = 'n'

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 3

              
class TestIOUtils(keras_parameterized.TestCase):

  def test_ask_to_proceed_with_overwrite(self):
    with tf.compat.v1.test.mock.patch.object(builtins, 'input') as mock_log:
      mock_log.return_value = 'y'
      self.assertTrue(io_utils.ask_to_proceed_with_overwrite('/tmp/not_exists'))

      mock_log.return_value = 'n'

            

Reported by Pylint.