mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
mypy: Enable strict optional for lib/exceptions.
Change return type of reduce_ex to pass under stricter conditions.
This commit is contained in:
2
mypy.ini
2
mypy.ini
@@ -316,7 +316,7 @@ strict_optional = False
|
|||||||
[mypy-zerver.lib.events] # signup_notifications_stream is Optional, but accessing id property
|
[mypy-zerver.lib.events] # signup_notifications_stream is Optional, but accessing id property
|
||||||
strict_optional = True
|
strict_optional = True
|
||||||
[mypy-zerver.lib.exceptions] #21: error: Return type of "__reduce_ex__" incompatible with supertype "object"
|
[mypy-zerver.lib.exceptions] #21: error: Return type of "__reduce_ex__" incompatible with supertype "object"
|
||||||
strict_optional = False
|
strict_optional = True
|
||||||
[mypy-zerver.lib.bugdown.api_arguments_table_generator] #18: error: Item "None" of "Optional[Dict[str, Any]]" has no attribute "items"
|
[mypy-zerver.lib.bugdown.api_arguments_table_generator] #18: error: Item "None" of "Optional[Dict[str, Any]]" has no attribute "items"
|
||||||
strict_optional = False
|
strict_optional = False
|
||||||
[mypy-zerver.lib.message] #868: error: Unsupported operand types for - ("Optional[int]" and "int")
|
[mypy-zerver.lib.message] #868: error: Unsupported operand types for - ("Optional[int]" and "int")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Dict, List, Optional, Type
|
from typing import Any, Dict, List, Optional, Type
|
||||||
|
from mypy_extensions import NoReturn
|
||||||
|
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
@@ -20,7 +21,7 @@ class AbstractEnum(Enum):
|
|||||||
def value(self) -> None:
|
def value(self) -> None:
|
||||||
raise AssertionError("Not implemented")
|
raise AssertionError("Not implemented")
|
||||||
|
|
||||||
def __reduce_ex__(self, proto: int) -> None:
|
def __reduce_ex__(self, proto: int) -> NoReturn:
|
||||||
raise AssertionError("Not implemented")
|
raise AssertionError("Not implemented")
|
||||||
|
|
||||||
class ErrorCode(AbstractEnum):
|
class ErrorCode(AbstractEnum):
|
||||||
|
|||||||
Reference in New Issue
Block a user