mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
mypy: enable strict optional for lib/message.
Add assert in order to pass checks under strict conditions.
This commit is contained in:
2
mypy.ini
2
mypy.ini
@@ -320,7 +320,7 @@ strict_optional = True
|
||||
[mypy-zerver.lib.bugdown.api_arguments_table_generator] #18: error: Item "None" of "Optional[Dict[str, Any]]" has no attribute "items"
|
||||
strict_optional = True
|
||||
[mypy-zerver.lib.message] #868: error: Unsupported operand types for - ("Optional[int]" and "int")
|
||||
strict_optional = False
|
||||
strict_optional = True
|
||||
|
||||
[mypy-zerver.migrations.0077_add_file_name_field_to_realm_emoji] #73: error: Argument 2 to "upload_files" of "Uploader" has incompatible type "Optional[bytes]"; expected "bytes"
|
||||
strict_optional = False
|
||||
|
||||
@@ -893,6 +893,8 @@ def maybe_update_first_visible_message_id(realm: Realm, lookback_hours: int) ->
|
||||
|
||||
def update_first_visible_message_id(realm: Realm) -> None:
|
||||
try:
|
||||
# We have verified that the limit is not none before calling this function.
|
||||
assert realm.message_visibility_limit is not None
|
||||
first_visible_message_id = Message.objects.filter(sender__realm=realm).values('id').\
|
||||
order_by('-id')[realm.message_visibility_limit - 1]["id"]
|
||||
except IndexError:
|
||||
|
||||
Reference in New Issue
Block a user