Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.14.z] Use type(self) instead of entity class name in create methods #1146

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,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 @@ -3066,7 +3066,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 @@ -3560,7 +3560,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 @@ -3640,7 +3640,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 @@ -4280,7 +4280,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 @@ -5377,7 +5377,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 @@ -5454,7 +5454,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 @@ -5719,7 +5719,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 @@ -6580,7 +6580,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 @@ -8160,7 +8160,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 @@ -8331,7 +8331,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 @@ -8608,7 +8608,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 @@ -8727,7 +8727,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
Loading