Skip to content

Commit

Permalink
Use type(self) instead of entity class name in create methods.
Browse files Browse the repository at this point in the history
(cherry picked from commit d5545c1)
  • Loading branch information
tpapaioa authored and web-flow committed May 23, 2024
1 parent c41a796 commit 53c4343
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 @@ -1491,7 +1491,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 @@ -3047,7 +3047,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 @@ -3541,7 +3541,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 @@ -3621,7 +3621,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 @@ -4173,7 +4173,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 @@ -5230,7 +5230,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 @@ -5307,7 +5307,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 @@ -5572,7 +5572,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 @@ -6433,7 +6433,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 @@ -8013,7 +8013,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 @@ -8184,7 +8184,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 @@ -8461,7 +8461,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 @@ -8580,7 +8580,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 53c4343

Please sign in to comment.