The following issues were found

keras/utils/tf_contextlib.py
5 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""TFDecorator-aware replacements for the contextlib module."""

import tensorflow.compat.v2 as tf

import contextlib as _contextlib


def contextmanager(target):

            

Reported by Pylint.

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

Line: 19 Column: 1

              
import tensorflow.compat.v2 as tf

import contextlib as _contextlib


def contextmanager(target):
  """A tf_decorator-aware wrapper for `contextlib.contextmanager`.


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 23 Column: 1

              

def contextmanager(target):
  """A tf_decorator-aware wrapper for `contextlib.contextmanager`.

  Usage is identical to `contextlib.contextmanager`.

  Args:
    target: A callable to be wrapped in a contextmanager.

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 32 Column: 1

                Returns:
    A callable that can be used inside of a `with` statement.
  """
  context_manager = _contextlib.contextmanager(target)
  return tf.__internal__.decorator.make_decorator(target, context_manager, 'contextmanager')

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 33 Column: 1

                  A callable that can be used inside of a `with` statement.
  """
  context_manager = _contextlib.contextmanager(target)
  return tf.__internal__.decorator.make_decorator(target, context_manager, 'contextmanager')

            

Reported by Pylint.

keras/__init__.py
4 issues
Unable to import 'tensorflow.python'
Error

Line: 21 Column: 1

              [keras.io](https://keras.io).
"""
# pylint: disable=unused-import
from tensorflow.python import tf2
from keras import distribute

# See b/110718070#comment18 for more details about this import.
from keras import models


            

Reported by Pylint.

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

Line: 31 Column: 1

              from keras.engine.sequential import Sequential
from keras.engine.training import Model

from tensorflow.python.util.tf_export import keras_export

__version__ = '2.7.0'

keras_export('keras.__version__').export_constant(__name__, '__version__')

            

Reported by Pylint.

Imports from package tensorflow are not grouped
Error

Line: 31 Column: 1

              from keras.engine.sequential import Sequential
from keras.engine.training import Model

from tensorflow.python.util.tf_export import keras_export

__version__ = '2.7.0'

keras_export('keras.__version__').export_constant(__name__, '__version__')

            

Reported by Pylint.

third party import "from tensorflow.python.util.tf_export import keras_export" should be placed before "from keras import distribute"
Error

Line: 31 Column: 1

              from keras.engine.sequential import Sequential
from keras.engine.training import Model

from tensorflow.python.util.tf_export import keras_export

__version__ = '2.7.0'

keras_export('keras.__version__').export_constant(__name__, '__version__')

            

Reported by Pylint.

keras/preprocessing/__init__.py
4 issues
Bad option value 'g-import-not-at-top'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Provides keras data preprocessing utils to pre-process tf.data.Datasets before they are fed to the model."""
# pylint: disable=g-import-not-at-top
# TODO(mihaimaruseac): remove the import of keras_preprocessing and injecting
# once we update to latest version of keras_preprocessing
import keras_preprocessing

from keras import backend

            

Reported by Pylint.

Unable to import 'keras_preprocessing'
Error

Line: 19 Column: 1

              # pylint: disable=g-import-not-at-top
# TODO(mihaimaruseac): remove the import of keras_preprocessing and injecting
# once we update to latest version of keras_preprocessing
import keras_preprocessing

from keras import backend
from keras.preprocessing import image
from keras.preprocessing import sequence
from keras.preprocessing import text

            

Reported by Pylint.

TODO(mihaimaruseac): remove the import of keras_preprocessing and injecting
Error

Line: 17 Column: 3

              # ==============================================================================
"""Provides keras data preprocessing utils to pre-process tf.data.Datasets before they are fed to the model."""
# pylint: disable=g-import-not-at-top
# TODO(mihaimaruseac): remove the import of keras_preprocessing and injecting
# once we update to latest version of keras_preprocessing
import keras_preprocessing

from keras import backend
from keras.preprocessing import image

            

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.
# ==============================================================================
"""Provides keras data preprocessing utils to pre-process tf.data.Datasets before they are fed to the model."""
# pylint: disable=g-import-not-at-top
# TODO(mihaimaruseac): remove the import of keras_preprocessing and injecting
# once we update to latest version of keras_preprocessing
import keras_preprocessing


            

Reported by Pylint.

keras/api/create_python_api_wrapper.py
3 issues
Unable to import 'keras'
Error

Line: 26 Column: 1

              from __future__ import division
from __future__ import print_function

import keras  # pylint: disable=unused-import
from tensorflow.python.tools.api.generator import create_python_api

if __name__ == '__main__':
  create_python_api.main()

            

Reported by Pylint.

Unable to import 'tensorflow.python.tools.api.generator'
Error

Line: 27 Column: 1

              from __future__ import print_function

import keras  # pylint: disable=unused-import
from tensorflow.python.tools.api.generator import create_python_api

if __name__ == '__main__':
  create_python_api.main()

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 30 Column: 1

              from tensorflow.python.tools.api.generator import create_python_api

if __name__ == '__main__':
  create_python_api.main()

            

Reported by Pylint.

keras/layers/normalization/batch_normalization_v1.py
3 issues
Bad option value 'g-classes-have-attributes'
Error

Line: 16 Column: 1

              # limitations under the License.
# ==============================================================================
"""Batch Normalization V1 layer."""
# pylint: disable=g-classes-have-attributes

from keras.layers.normalization import batch_normalization
from tensorflow.python.util.tf_export import keras_export



            

Reported by Pylint.

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

Line: 19 Column: 1

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

from keras.layers.normalization import batch_normalization
from tensorflow.python.util.tf_export import keras_export


# pylint: disable=missing-docstring
@keras_export(v1=['keras.layers.BatchNormalization'])
class BatchNormalization(batch_normalization.BatchNormalizationBase):

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 4
Style

Line: 25 Column: 1

              # pylint: disable=missing-docstring
@keras_export(v1=['keras.layers.BatchNormalization'])
class BatchNormalization(batch_normalization.BatchNormalizationBase):
  _USE_V2_BEHAVIOR = False

            

Reported by Pylint.

keras/benchmarks/eager_microbenchmarks_test.py
1 issues
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 204
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              

if __name__ == "__main__":
  assert tf.executing_eagerly()
  tf.test.main()

            

Reported by Bandit.

keras/layers/normalization/__init__.py
1 issues
Trailing newlines
Error

Line: 1 Column: 1

              

            

Reported by Pylint.

keras/layers/core/__init__.py
1 issues
Trailing newlines
Error

Line: 39 Column: 1

              
from keras.layers.core.tf_op_layer import SlicingOpLambda
from keras.layers.core.tf_op_layer import TFOpLambda


            

Reported by Pylint.

keras/distribute/model_combinations.py
1 issues
Unable to import 'tensorflow.compat.v2'
Error

Line: 17 Column: 1

              # ==============================================================================
"""Strategy and optimizer combinations for combinations.combine()."""

import tensorflow.compat.v2 as tf
from keras.distribute import simple_models

simple_functional_model = tf.__internal__.test.combinations.NamedObject(
    "SimpleFunctionalModel", simple_models.SimpleFunctionalModel())


            

Reported by Pylint.

keras/utils/mode_keys.py
1 issues
Unable to import 'tensorflow.python.saved_model.model_utils.mode_keys'
Error

Line: 18 Column: 1

              """Keras model mode constants."""

# pylint: disable=unused-import
from tensorflow.python.saved_model.model_utils.mode_keys import KerasModeKeys as ModeKeys
# pylint: enable=unused-import

            

Reported by Pylint.