diff --git a/modelscan/cli.py b/modelscan/cli.py index 1a232f2..eafc69b 100644 --- a/modelscan/cli.py +++ b/modelscan/cli.py @@ -132,7 +132,7 @@ def scan( raise click.UsageError("Command line must include a path") # Report scan results - if reporting_format is not "custom": + if reporting_format != "custom": modelscan._settings["reporting"]["module"] = DEFAULT_REPORTING_MODULES[ reporting_format ] diff --git a/modelscan/reports.py b/modelscan/reports.py index dbf9f86..f09159b 100644 --- a/modelscan/reports.py +++ b/modelscan/reports.py @@ -32,7 +32,7 @@ def generate( :param errors: Any errors that occurred during the scan. """ - raise NotImplemented + raise NotImplementedError class ConsoleReport(Report): @@ -75,7 +75,7 @@ def generate( f"\nTotal skipped: {len(scan.skipped)} - run with --show-skipped to see the full list." ) if settings["show_skipped"]: - print(f"\nSkipped files list:\n") + print("\nSkipped files list:\n") for file_name in scan.skipped: print(str(file_name)) diff --git a/modelscan/scanners/h5/scan.py b/modelscan/scanners/h5/scan.py index b0644a3..44a52c9 100644 --- a/modelscan/scanners/h5/scan.py +++ b/modelscan/scanners/h5/scan.py @@ -102,7 +102,7 @@ def _get_keras_h5_operator_names(self, model: Model) -> Optional[List[Any]]: with h5py.File(model.get_stream()) as model_hdf5: try: - if not "model_config" in model_hdf5.attrs.keys(): + if "model_config" not in model_hdf5.attrs.keys(): return None model_config = json.loads(model_hdf5.attrs.get("model_config", {})) diff --git a/modelscan/scanners/keras/scan.py b/modelscan/scanners/keras/scan.py index 54fd561..62feb76 100644 --- a/modelscan/scanners/keras/scan.py +++ b/modelscan/scanners/keras/scan.py @@ -91,7 +91,7 @@ def _scan_keras_config_file(self, model: Model) -> ScanResults: ModelScanError( self.name(), ErrorCategories.JSON_DECODE, - f"Not a valid JSON data", + "Not a valid JSON data", str(model.get_source()), ) ], diff --git a/modelscan/scanners/saved_model/scan.py b/modelscan/scanners/saved_model/scan.py index 54e53a0..811e5d8 100644 --- a/modelscan/scanners/saved_model/scan.py +++ b/modelscan/scanners/saved_model/scan.py @@ -2,9 +2,8 @@ import json import logging -from pathlib import Path -from typing import IO, List, Set, Union, Optional, Dict, Any +from typing import List, Set, Optional, Dict, Any try: import tensorflow diff --git a/modelscan/tools/picklescanner.py b/modelscan/tools/picklescanner.py index 0320529..eb722d0 100644 --- a/modelscan/tools/picklescanner.py +++ b/modelscan/tools/picklescanner.py @@ -260,7 +260,7 @@ def scan_pytorch(model: Model, settings: Dict[str, Any]) -> ScanResults: ModelScanSkipped( scan_name, SkipCategories.MAGIC_NUMBER, - f"Invalid magic number", + "Invalid magic number", str(model.get_source()), ) ], diff --git a/tests/test_utils.py b/tests/test_utils.py index 6fedb5e..52a195c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,7 +3,6 @@ import pickle import struct from typing import Any, Tuple -import os import torch import torch.nn as nn import tensorflow as tf