From 7228988b67ccad46fdd67237d45871dbe42e8f4b Mon Sep 17 00:00:00 2001 From: Eduardo Olivares Date: Wed, 20 Mar 2024 13:22:54 +0100 Subject: [PATCH] Simplify BaseResourceFixture.setup_client This avoids the following error on some branches: TypeError: Subscripted generics cannot be used with class and instance checks The method keystone.keystone_client already checks whether the keystone client was created before or not. Change-Id: Ic5f8a9908f07be894b41017b121e03068348c8b4 --- tobiko/openstack/base/_fixture.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tobiko/openstack/base/_fixture.py b/tobiko/openstack/base/_fixture.py index 7fca33cdb..9c5186800 100644 --- a/tobiko/openstack/base/_fixture.py +++ b/tobiko/openstack/base/_fixture.py @@ -59,15 +59,10 @@ class BaseResourceFixture(tobiko.SharedFixture): return self.setup_client().session def setup_client(self) -> keystone.KeystoneClient: - client = self.client - # NOTE(slaweq): it seems that due to bug - # https://github.com/python/mypy/issues/11673 - # in mypy this line is causing arg-type error so lets - # ignore it for now - if not isinstance( - client, keystone.KeystoneClient): # type: ignore[arg-type] - self.client = client = keystone.keystone_client(self.client) - return client + # returns self.client itself, if the keystone client was already + # created; else, creates a new keystone client and returns it. + self.client = keystone.keystone_client(self.client) + return self.client def ensure_quota_limits(self): """Ensures quota limits before creating a new stack