From 04c50cffa755ff8d1af6d6fe9bcdcede0f083cdb Mon Sep 17 00:00:00 2001 From: jkiely Date: Thu, 17 May 2018 11:32:40 -0400 Subject: [PATCH] mypy: Enable strict optional in zerver/lib/bugdown. Explicitly check for none in optional value and set it to a dict. --- mypy.ini | 2 +- zerver/lib/bugdown/api_arguments_table_generator.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mypy.ini b/mypy.ini index a4b48ea25a..e2e675df11 100644 --- a/mypy.ini +++ b/mypy.ini @@ -318,7 +318,7 @@ strict_optional = True [mypy-zerver.lib.exceptions] #21: error: Return type of "__reduce_ex__" incompatible with supertype "object" 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 = False +strict_optional = True [mypy-zerver.lib.message] #868: error: Unsupported operand types for - ("Optional[int]" and "int") strict_optional = False diff --git a/zerver/lib/bugdown/api_arguments_table_generator.py b/zerver/lib/bugdown/api_arguments_table_generator.py index 523f923082..e02569f4bf 100644 --- a/zerver/lib/bugdown/api_arguments_table_generator.py +++ b/zerver/lib/bugdown/api_arguments_table_generator.py @@ -11,7 +11,9 @@ REGEXP = re.compile(r'\{generate_api_arguments_table\|\s*(.+?)\s*\|\s*(.+?)\s*\} class MarkdownArgumentsTableGenerator(Extension): - def __init__(self, configs: Optional[Dict[str, Any]]={}) -> None: + def __init__(self, configs: Optional[Dict[str, Any]]=None) -> None: + if configs is None: + configs = {} self.config = { 'base_path': ['.', 'Default location from which to evaluate relative paths for the JSON files.'], }