Skip to content

Commit

Permalink
review actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Jul 7, 2021
1 parent 15c8ae1 commit 4293187
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
11 changes: 4 additions & 7 deletions lib/iris/common/metadata.py
Expand Up @@ -1344,10 +1344,12 @@ def __init__(self, cls, **kwargs):
#: The metadata class to be manufactured by this factory.
self.cls = cls

# Proxy for self.cls._fields
# Proxy for self.cls._fields for later internal use, as this
# saves on indirect property lookup via self.cls
self._fields = cls._fields

# Initialise the metadata class fields in the instance.
# Use cls directly here since it's available.
for field in cls._fields:
setattr(self, field, None)

Expand Down Expand Up @@ -1411,12 +1413,7 @@ def values(self):
fields = {field: getattr(self, field) for field in self._fields}
return self.cls(**fields)

# Restrict factory to appropriate metadata classes only.
if not issubclass(cls, BaseMetadata):
emsg = "Require a subclass of {!r}, got {!r}."
raise TypeError(emsg.format(BaseMetadata.__name__, cls))

# Define the name, (inheritance) bases and namespace of the dynamic class.
# Define the name, (inheritance) bases, and namespace of the dynamic class.
name = "MetadataManager"
bases = ()
namespace = {
Expand Down
Expand Up @@ -36,14 +36,6 @@


class Test_factory(tests.IrisTest):
def test__subclass_invalid(self):
class Other:
pass

emsg = "Require a subclass of 'BaseMetadata'"
with self.assertRaisesRegex(TypeError, emsg):
_ = metadata_manager_factory(Other)

def test__kwargs_invalid(self):
emsg = "Invalid 'BaseMetadata' field parameters, got 'wibble'."
with self.assertRaisesRegex(ValueError, emsg):
Expand Down

0 comments on commit 4293187

Please sign in to comment.