From 2a327582f71bf22e32ae6c9f5419d89cb68acf7a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 14 Dec 2023 21:47:34 +0900 Subject: [PATCH] Unpin flake8-import-order ... to resolve the following ValueError. ``` ValueError: 'string' is not callable ``` The I202 test is disabled because multiple files need updates. It may be enabled later once all the warnings are addressed. Fixed E721 test errors which appears 4 times. E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()` Change-Id: I68880b83c8a555ed30c3ce18b73ae27b8db34dc8 --- octavia/certificates/manager/local.py | 8 ++++---- test-requirements.txt | 2 +- tox.ini | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/octavia/certificates/manager/local.py b/octavia/certificates/manager/local.py index a19224b827..da1d653557 100644 --- a/octavia/certificates/manager/local.py +++ b/octavia/certificates/manager/local.py @@ -50,9 +50,9 @@ class LocalCertManager(cert_mgr.CertManager): """ cert_ref = str(uuid.uuid4()) filename_base = os.path.join(CONF.certificates.storage_path, cert_ref) - if type(certificate) == bytes: + if isinstance(certificate, bytes): certificate = certificate.decode('utf-8') - if type(private_key) == bytes: + if isinstance(private_key, bytes): private_key = private_key.decode('utf-8') LOG.info("Storing certificate data on the local filesystem.") @@ -71,7 +71,7 @@ class LocalCertManager(cert_mgr.CertManager): if intermediates: filename_intermediates = "{0}.int".format(filename_base) - if type(intermediates) == bytes: + if isinstance(intermediates, bytes): intermediates = intermediates.decode('utf-8') with os.fdopen(os.open( filename_intermediates, flags, mode), 'w') as int_file: @@ -79,7 +79,7 @@ class LocalCertManager(cert_mgr.CertManager): if private_key_passphrase: filename_pkp = "{0}.pass".format(filename_base) - if type(private_key_passphrase) == bytes: + if isinstance(private_key_passphrase, bytes): private_key_passphrase = private_key_passphrase.decode( 'utf-8') with os.fdopen(os.open( diff --git a/test-requirements.txt b/test-requirements.txt index 051ebbdf3f..917eeb7d3a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,7 +5,7 @@ hacking>=3.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD -flake8-import-order==0.12 # LGPLv3 +flake8-import-order # LGPLv3 python-subunit>=1.0.0 # Apache-2.0/BSD oslotest>=3.2.0 # Apache-2.0 pylint>=2.5.3 # GPLv2 diff --git a/tox.ini b/tox.ini index ff61eceb53..7f4cd85780 100644 --- a/tox.ini +++ b/tox.ini @@ -147,7 +147,8 @@ commands = bandit -r octavia -ll -ii -x tests [flake8] # [H104]: Empty file with only comments # [W504]: Line break after binary operator -ignore = H104,W504 +# [I202]: Additional newline in a group of imports. +ignore = H104,W504,I202 show-source = true builtins = _ exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build