Skip to content

Commit

Permalink
style: 🩹 use != with literal
Browse files Browse the repository at this point in the history
As of Python 3.8, using is and is not with constant literals will produce a SyntaxWarning.
  • Loading branch information
CandiedCode committed Apr 6, 2024
1 parent 0eeb158 commit 56d78de
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modelscan/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
4 changes: 2 additions & 2 deletions modelscan/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate(
:param errors: Any errors that occurred during the scan.
"""
raise NotImplemented
raise NotImplementedError


class ConsoleReport(Report):
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion modelscan/scanners/h5/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {}))
Expand Down
2 changes: 1 addition & 1 deletion modelscan/scanners/keras/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
)
],
Expand Down
3 changes: 1 addition & 2 deletions modelscan/scanners/saved_model/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modelscan/tools/picklescanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
)
],
Expand Down
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 56d78de

Please sign in to comment.