-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Improve datastore type hints #14678
base: develop
Are you sure you want to change the base?
Improve datastore type hints #14678
Conversation
(I should probably mention that this would need to be expanded to the other datastore classes, e.g. for workers, etc.) |
73f2fdb
to
7e4ef0f
Compare
This needs a bit more to get it working with all the various datastores we create... |
7b54466
to
9796706
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay so far.
I think we're missing a few things before we can apply this pattern to the rest of the stores.
CacheInvalidationWorkerStore
andSQLBaseStore
assume there is only one instance of themselves. Is there a plan for how we're going to handle them?- The bit of
SQLBaseStore
that involvesexternal_cached_functions
won't work for split out stores. I'm not sure what it does. process_replication_rows
andprocess_replication_position
won't get called on split out stores right now, so the massive chain of overrides andsuper()
calls will break. We'd probably want to refactor things to avoid the massive chain anyway, and have stores register their interest in particular row types.
try: | ||
store = getattr(self, store_name) | ||
except AttributeError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be ignoring store_name
s that refer to missing fields here?
I'm going to put this back in the queue in case anyone has more thoughts. |
I'm failing to see how we would end up with more than one (per process)? Or are you just suggesting it might be possible to do that somehow?
Good-catch, I think we need to do something similar to
This sounds like a good change to make regardless, maybe I'll just do this as a separate PR. |
It's more that every store inherits from one of the two. Even now with this PR, I think there are two (I'm not suggesting that there should be exactly one or we should support multiple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to add to Sean's review — looks sensible overall and given this has stuck around for a while in the queue I don't think anyone else has any objections.
By being explicit about methods we should be able to get better type checking (although this isn't entirely proven in this PR). The idea is to mostly treat datastores the way we handle config classes, each as an individual unit that has to reach back to a "root" object to query other datastores.
This means that the main
DataStore
object would become a bundle ofSQLBaseStore
objects instead of a single entity which has super-classes ofSQLBaseStore
.As a proof-of-concept I converted the
RelationsStore
(it is simple and I know it fairly well). Other stores could be done in follow-ups.Related to #11165
Downsides of this approach is it might make #11733 worse as you now have a
DataStore
which includes aRelationsStore
? It adds another layer to the puzzle.