This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Type annotations in synapse.databases.main.devices
#13025
Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3aa4fd2
Make DeviceWorkerStore inherit from EndToEndKeyWorkerStore
fecad1c
`key_values` should be a Collection, not an Iterable
cd24240
correct `get_cached_device_list_changes`
d4acc84
Widen the type of user_ids_to_check
c195d07
Explicit annotations mypy couldn't deduce
ff49f67
Suppress a late-binding problem
ad0f4db
Workaround invariance of Dict
09ad3c4
Annotate a transaction's signature
e458d79
annotate an LRU cache
a86da20
Correct type of `context`
d204223
Type-ignore the weird stuff
0c8f7ad
devices is typed
62d692c
Changelog
a1bf0c2
import Literal from typing_extensions
81cf5d0
Batch of suggestions from Patrick
33e6ecc
List comprehension is neater here
a3257bb
Ugh, missed a line
ac6670c
Fix typo
1569b14
Revert "Correct type of `context`"
134d3da
Fix the context complaint differently
8395995
Revert "Fix the context complaint differently"
60e2ce0
Allow context=None in _add_device_outbound_poke_to_stream_txn
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I wasn't sure I liked this one. The original complaint was
Which corresponds to the
context
argument of this function:synapse/synapse/storage/databases/main/devices.py
Lines 1709 to 1756 in 9dc3293
If we pass
context=None
, we'll first transform it to a JSONnull
and store that blob of json as the four-codepoint stringnull
. I don't think that's what we want!!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.
Note that
opentracing_context
is a nullable text field in the DB: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.
Do you know if we have any
"null"
data already stored though? It is very unclear to me if it is safe to change this.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.
Not on matrix.org:
I suppose a safer approach would be to write a migration which makes the column non-nullable.
Maybe this is better dropped though; ideally type hints wouldn't kick off invasive changes.
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.
1569b14 reverts this and 134d3da presents an alternative.
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.
Thanks. I'd be curious what @erikjohnston thinks here since this was was just added in #12321 (and maybe #13045). Is there a long term plan here we're unsure about?
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.
I'm a bit confused as to why we can't let it be
None
if I'm honest?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.
I was mainly just trying to keep the existing type hints happy. Some of them say
Dict[]
and some of them sayOptional[Dict]
.Maybe we just use
Optional[Dict]
everywhere?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.
Yeah, I'd go with
Optional[Dict]
if the DB has a nullable column?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.
8395995 and 60e2ce0 do this.