Skip to content

Commit

Permalink
Use type(self) instead of entity class name in create methods. (#1144)
Browse files Browse the repository at this point in the history
(cherry picked from commit d5545c1)

Co-authored-by: Tasos Papaioannou <tpapaioa@redhat.com>
  • Loading branch information
Satellite-QE and tpapaioa authored May 28, 2024
1 parent 19b2929 commit d997df9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1381129>`_.
"""
return DiscoveryRule(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -3150,7 +3150,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1219654>`_.
"""
return Domain(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -3644,7 +3644,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1654383>`_.
"""
return HostCollection(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -3724,7 +3724,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1235377>`_.
"""
return HostGroup(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -4364,7 +4364,7 @@ def create(self, create_missing=None):
For more information, see `Bugzilla #1449749
<https://bugzilla.redhat.com/show_bug.cgi?id=1449749>`_.
"""
return Host(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -5417,7 +5417,7 @@ def create(self, create_missing=None):
"""
attrs = self.create_json(create_missing)
return Location(self._server_config, id=attrs['id']).read()
return type(self)(self._server_config, id=attrs['id']).read()

def read(self, entity=None, attrs=None, ignore=None, params=None):
"""Work around a bug in the server's response.
Expand Down Expand Up @@ -5494,7 +5494,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1219653>`_.
"""
return Media(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -5759,7 +5759,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1230873>`_.
"""
return Organization(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -6620,7 +6620,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1232855>`_.
"""
return Realm(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -8200,7 +8200,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1381129>`_.
"""
return TailoringFile(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -8371,7 +8371,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1301658>`_.
"""
return UserGroup(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -8648,7 +8648,7 @@ def create(self, create_missing=None):
<https://bugzilla.redhat.com/show_bug.cgi?id=1381129>`_.
"""
return ScapContents(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down Expand Up @@ -8767,7 +8767,7 @@ def create(self, create_missing=None):
"""
self._fields['event'] = entity_fields.StringField(required=True, choices=self.get_events())

return Webhooks(
return type(self)(
self._server_config,
id=self.create_json(create_missing)['id'],
).read()
Expand Down

0 comments on commit d997df9

Please sign in to comment.