jRPC responses are pumped through SomeResult.from_json(data) to convert dicts to proper data classes.
the from_json() classmethod though is capable of doing so many different things...
it can accept the class itself, returns data unchanged
it can accept a plain string, which would be assumed to be JSON and then:
it can accept a dict, which would be converted to this data class, processing properties recursively
it can accept a list, which merged elements' content into a single dict, WAT?
it can accept "other", returning None
this means that the classmethod has a weird return type, Self|None which has cascading effects on all the users of any facade call.
Urgency
Casually reporting
Python-libjuju version
3.5.2
Juju version
any
Reproduce / Test
class ApplicationInfoResults(Type):
_toSchema = {'results': 'results'}
_toPy = {'results': 'results'}
def __init__(self, results=None, **unknown_fields):
'''
results : typing.Sequence[~ApplicationInfoResult]
'''
results_ = [ApplicationInfoResult.from_json(o) for o in results or []]
# Validate arguments against known Juju API types.
if results_ is not None and not isinstance(results_, (bytes, str, list)):
raise Exception("Expected results_ to be a Sequence, received: {}".format(type(results_)))
self.results = results_
from typing import reveal_type
W reveal_type(self.results) # W: Type of "self.results" is "list[ApplicationInfoResult | None]"
self.unknown_fields = unknown_fields
Description
jRPC responses are pumped through
SomeResult.from_json(data)
to convert dicts to proper data classes.the
from_json()
classmethod though is capable of doing so many different things...this means that the classmethod has a weird return type,
Self|None
which has cascading effects on all the users of any facade call.Urgency
Casually reporting
Python-libjuju version
3.5.2
Juju version
any
Reproduce / Test