Closed brandomando closed 3 years ago
This causes issue with the dict
method of the GlobalState object when you're trying to return the dict of the data
attribute of a Nornir
object because it doesn't have a self
since the class is returned and not the instance of it.
def dict(self) -> Dict[str, Any]:
""" Return a dictionary representing the object. """
return {item: getattr(self, item) for item in GlobalState.__slots__}
GlobalState
used to be a singleton but that's no longer true so I think this is a leftover. As a matter of fact, state
is redundant as data
is what we care about nowadays.
I thought that might be the case. I will submit a PR to remove it.
Thanks!
https://github.com/nornir-automation/nornir/blob/e4f6b8c6258ae2dcfb286098b30652c7a31ecf30/nornir/core/__init__.py#L177
I'm not sure if this is intended behavior but it is a bit confusing to me why there would be a need to return the
GlobalState
class rather than the instantiated object like thedata
attribute, which is an instance ofGlobalState
.