Skip to content

Commit 4834b38

Browse files
committed
Use isinstance instead of type(x)==y
1 parent 85a32a9 commit 4834b38

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

juju/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ async def deploy(
17051705
if trust and (self.info.agent_version < client.Number.from_json('2.4.0')):
17061706
raise NotImplementedError("trusted is not supported on model version {}".format(self.info.agent_version))
17071707

1708-
if not all([type(st) == str for st in attach_storage]):
1708+
if not all([isinstance(st, str) for st in attach_storage]):
17091709
raise JujuError("Expected attach_storage to be a list of strings, given {}".format(attach_storage))
17101710

17111711
# Ensure what we pass in, is a string.
@@ -2658,7 +2658,7 @@ def _raise_for_status(entities, status):
26582658
))
26592659

26602660
if wait_for_exact_units is not None:
2661-
assert type(wait_for_exact_units) == int and wait_for_exact_units >= 0, \
2661+
assert isinstance(wait_for_exact_units, int) and wait_for_exact_units >= 0, \
26622662
'Invalid value for wait_for_exact_units : %s' % wait_for_exact_units
26632663

26642664
while True:

juju/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def parse_base_arg(base):
419419
:param base str : The base to deploy a charm (e.g. ubuntu@22.04)
420420
"""
421421
client.CharmBase()
422-
if type(base) != str or "@" not in base:
422+
if not isinstance(base, str) or "@" not in base:
423423
raise errors.JujuError(f"expected base string to contain os and channel separated by '@', got : {base}")
424424

425425
name, channel = base.split('@')

tests/integration/test_charmhub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async def test_info(event_loop):
1919
assert charm_info['id'] == 'Hw30RWzpUBnJLGtO71SX8VDWvd3WrjaJ'
2020
assert '2.0/stable' in charm_info['channel-map']
2121
cm_rev = charm_info['channel-map']['2.0/stable']['revision']
22-
if type(cm_rev) == dict:
22+
if isinstance(cm_rev, dict):
2323
# New client (>= 3.0)
2424
assert cm_rev['revision'] == 22
2525
else:
@@ -135,4 +135,4 @@ async def test_subordinate_false_field_exists(event_loop):
135135
async def test_list_resources(event_loop):
136136
async with base.CleanModel() as model:
137137
resources = await model.charmhub.list_resources('hello-kubecon')
138-
assert type(resources) == list and len(resources) > 0
138+
assert isinstance(resources, list) and len(resources) > 0

0 commit comments

Comments
 (0)