-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[tracking issue] Validation through Invariance #8376
Comments
One thing I still want the core team's opinion on: What is the best way I could properly and idiomatically change some functions that build and return data? (so that passing around this data is still valid by type) What I mean by this; How should I change e.g. @attr.s(slots=True)
class RoomStatsDelta:
current_state_events = attr.ib(default=0)
joined_members = attr.ib(default=0)
invited_members = attr.ib(default=0)
left_members = attr.ib(default=0)
banned_members = attr.ib(default=0) This allows the program pass around objects which are assured to have those values. The Later on, when sending this to the user, (This could also (maybe) be a very good candidate for #8361) |
For this particular example I'm not sure if deltas are ever sent as JSON or if it is completely an internal data-structure. Note that in this case it seems like the |
I do note that, but I wanted to pick an easy example for the moment. It seems like I cant subclass Still, eliminating "blind key-getting/setting" is the point here; to make sure the static linter can follow what's going on. Edit: seems like these eventually end up under Edit 2: and it looks like keys added to |
I think #8351 covers most of this, the other part (making every class statically verifiable) should be hit at some point as well, but i'm going to close this as it's not exactly doing much good being open onto itself. |
Description
This is a tracking issue for PRs and issues related to invariance in the synapse codebase, to ensure extra stability and reduce undefined behaviour.
The plan is two-fold:
Small PRs will be introduced cleaning these up iteratively.
PRs
To-Dos / Spotted Issues
synapse.server.HomeServer.__init__()
from dynamic to static behaviour.(e.g. by adding
__init__()
signatures to subclasses, then disallowing receiving**kwargs
)The text was updated successfully, but these errors were encountered: