Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 96d9215

Browse files
authored
Update type of EventContext.rejected (#13460)
1 parent e9e6aac commit 96d9215

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

changelog.d/13460.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update type of `EventContext.rejected`.

synapse/events/snapshot.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
14+
from typing import TYPE_CHECKING, List, Optional, Tuple
1515

1616
import attr
1717
from frozendict import frozendict
18-
from typing_extensions import Literal
1918

2019
from synapse.appservice import ApplicationService
2120
from synapse.events import EventBase
@@ -33,7 +32,7 @@ class EventContext:
3332
Holds information relevant to persisting an event
3433
3534
Attributes:
36-
rejected: A rejection reason if the event was rejected, else False
35+
rejected: A rejection reason if the event was rejected, else None
3736
3837
_state_group: The ID of the state group for this event. Note that state events
3938
are persisted with a state group which includes the new event, so this is
@@ -85,7 +84,7 @@ class EventContext:
8584
"""
8685

8786
_storage: "StorageControllers"
88-
rejected: Union[Literal[False], str] = False
87+
rejected: Optional[str] = None
8988
_state_group: Optional[int] = None
9089
state_group_before_event: Optional[int] = None
9190
_state_delta_due_to_event: Optional[StateMap[str]] = None

synapse/storage/databases/main/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ def event_dict(event: EventBase) -> JsonDict:
14901490
event.sender,
14911491
"url" in event.content and isinstance(event.content["url"], str),
14921492
event.get_state_key(),
1493-
context.rejected or None,
1493+
context.rejected,
14941494
)
14951495
for event, context in events_and_contexts
14961496
),

0 commit comments

Comments
 (0)