From: Vagisha Gupta Date: Fri, 15 Mar 2019 12:57:46 +0000 (+0530) Subject: Cleanup unused import and use isinstance() instead of type() X-Git-Tag: 1.2.0rc1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=965fee1b37e489fd65162c89c139574a3aa84ca3;p=thirdparty%2Fsuricata-update.git Cleanup unused import and use isinstance() instead of type() 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. --- diff --git a/suricata/update/main.py b/suricata/update/main.py index 883afa7..1f91d2d 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -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)