-
Notifications
You must be signed in to change notification settings - Fork 122
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
feat: narrow the type for 'app' and 'unit' in relation events #1032
feat: narrow the type for 'app' and 'unit' in relation events #1032
Conversation
The grafana-k8s-operator tests assume that |
Yeah, I think that assessment is probably right: it's probably too much to change the signature here, even if that test shouldn't really be doing that. So let's leave |
* Assume that the application will always be provided for relation events, even though there is an open Juju bug that indicates that may not always be the case at the moment. * Minor style fixes. * Don't adjust the types in the , as charmers may be relying on the default value in tests, and there's no valid default value other than None.
app
is always provided for relation events, except for relation-broken (which may be a Juju bug), so for all of the relation event classes, make the typeApplication
rather thanApplication|None
.unit
may be provided for relation-changed, and is provided for unit level relation events (joined, departed), but is not provided for application level events (created, broken), so adjust the types in the relation event classes to be eitherNone
orUnit
as applicable.The
RelationCreated
andRelationBroken
classes do now have an oddunit
attribute that is defined as always being None, but that was the actual case before and we're just being explicit about it now. I assume dropping the attribute would be too much of a backwards compatibility issue.Similarly, the
__init__
for the various event classes still acceptNone
forapp
andunit
even when they are actually always expected. This is unfortunate, but is stuck for backwards compatibility. Generally, we are the one creating the event objects, not the charmer, so the inexact types in the__init__
shouldn't impact charmers.Fixes #976