From 0f8edb3373f0a4fb64fb53ccea7f0532e05c5e3c Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Sat, 26 Aug 2023 16:58:38 +0200 Subject: [PATCH] More fixes for ruff warnings about type checking Signed-off-by: Mattia Verga --- bodhi-server/bodhi/server/tasks/composer.py | 4 ++-- bodhi-server/tests/test_config.py | 2 +- bodhi-server/tests/test_models.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bodhi-server/bodhi/server/tasks/composer.py b/bodhi-server/bodhi/server/tasks/composer.py index 8cef20e954..82325be476 100644 --- a/bodhi-server/bodhi/server/tasks/composer.py +++ b/bodhi-server/bodhi/server/tasks/composer.py @@ -1430,11 +1430,11 @@ def _raise_on_get_build_multicall_error(self, result, build): build (bodhi.server.models.Build): build for which the koji.multiCall() returned this result. """ - if type(result) is list and not result: + if isinstance(result, list) and not result: err = 'Empty list returned for getBuild("%s").' % build.nvr log.error(err) raise Exception(err) - elif type(result) is not list: + elif not isinstance(result, list): err = 'Unexpected data returned for getBuild("%s"): %r.' \ % (build.nvr, result) log.error(err) diff --git a/bodhi-server/tests/test_config.py b/bodhi-server/tests/test_config.py index 023e630a61..ba766ccefe 100644 --- a/bodhi-server/tests/test_config.py +++ b/bodhi-server/tests/test_config.py @@ -229,7 +229,7 @@ def test_koji_settings_are_strs(self): c._validate() for k in ('koji_hub', 'krb_ccache', 'krb_keytab', 'krb_principal'): - assert type(c[k]) is str + assert isinstance(c[k], str) # And the values should match what we did above. assert c['koji_hub'] == 'http://example.com/kojihub' assert c['krb_ccache'] == '/tmp/krb5cc_%{uid}' diff --git a/bodhi-server/tests/test_models.py b/bodhi-server/tests/test_models.py index 5fb54236ed..b8eb9120ef 100644 --- a/bodhi-server/tests/test_models.py +++ b/bodhi-server/tests/test_models.py @@ -70,7 +70,7 @@ class ModelTest(BasePyTestCase): def setup_method(self): super(ModelTest, self).setup_method(self) buildsys.setup_buildsystem({'buildsystem': 'dev'}) - if type(self) is not ModelTest: + if type(self) is not ModelTest: # noqa: E721 try: new_attrs = {} new_attrs.update(self.attrs) @@ -439,7 +439,7 @@ def test___iter__(self): for v in iter(m): assert repr(v) == '<{}>'.format(expected_values.pop(0)) - assert type(v) is model.EnumSymbol + assert type(v) is model.EnumSymbol # noqa: E721 assert expected_values == [] @@ -497,7 +497,7 @@ def test___str__(self): s = model.EnumSymbol(model.UpdateStatus, 'name', 'value', 'description') assert str(s) == 'value' - assert type(str(s)) == str + assert isinstance(str(s), str) class TestCompose(BasePyTestCase):