This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
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.
Type annotations in
synapse.databases.main.devices
#13025Type annotations in
synapse.databases.main.devices
#13025Changes from 16 commits
3aa4fd2
fecad1c
cd24240
d4acc84
c195d07
ff49f67
ad0f4db
09ad3c4
e458d79
a86da20
d204223
0c8f7ad
62d692c
a1bf0c2
81cf5d0
33e6ecc
a3257bb
ac6670c
1569b14
134d3da
8395995
60e2ce0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.