]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Cleanup unused import and use isinstance() instead of type()
authorVagisha Gupta <vagishagupta23@gmail.com>
Fri, 15 Mar 2019 12:57:46 +0000 (18:27 +0530)
committerJason Ish <ish@unx.ca>
Thu, 17 Oct 2019 23:06:29 +0000 (17:06 -0600)
Optimization Cleanup main imports

`import types` is an unused import in main.py, therefore, removed.
Also, using `isinstance()` is the preferred way to access the type.
The isinstance() function checks if the object (first argument)
is an instance or subclass of classinfo class (second argument).
Here object is the 'url' to be checked and classinfo is a string
type.

suricata/update/main.py

index 883afa7878ebefc3f19b70cd973c2fff3683bf6d..1f91d2deb67eacccb925abae1cb6f23df126d4b8 100644 (file)
@@ -27,7 +27,6 @@ import time
 import hashlib
 import fnmatch
 import subprocess
-import types
 import shutil
 import glob
 import io
@@ -1018,7 +1017,7 @@ def load_sources(suricata_version):
 
     if config.get("sources"):
         for url in config.get("sources"):
-            if type(url) not in [type("")]:
+            if not isinstance(url, str):
                 raise exceptions.InvalidConfigurationError(
                     "Invalid datatype for source URL: %s" % (str(url)))
             url = (url % internal_params, http_header, checksum)