diff --git a/mypy.ini b/mypy.ini index e1676eb..fd727ea 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,3 +11,4 @@ show_traceback = True warn_no_return = True warn_redundant_casts = True warn_unused_ignores = True +warn_unreachable = True diff --git a/zulip/integrations/codebase/zulip_codebase_config.py b/zulip/integrations/codebase/zulip_codebase_config.py index 51d5de5..5ea2ed2 100644 --- a/zulip/integrations/codebase/zulip_codebase_config.py +++ b/zulip/integrations/codebase/zulip_codebase_config.py @@ -1,3 +1,5 @@ +from typing import Optional + # Change these values to configure authentication for your codebase account # Note that this is the Codebase API Username, found in the Settings page # for your account @@ -23,14 +25,14 @@ ZULIP_TICKETS_STREAM_NAME = "tickets" # If properly installed, the Zulip API should be in your import # path, but if not, set a custom path below -ZULIP_API_PATH = None +ZULIP_API_PATH: Optional[str] = None # Set this to your Zulip API server URI ZULIP_SITE = "https://zulip.example.com" # If you wish to log to a file rather than stdout/stderr, # please fill this out your desired path -LOG_FILE = None +LOG_FILE: Optional[str] = None # This file is used to resume this mirror in case the script shuts down. # It is required and needs to be writeable. diff --git a/zulip/integrations/codebase/zulip_codebase_mirror b/zulip/integrations/codebase/zulip_codebase_mirror index efdf899..45051be 100755 --- a/zulip/integrations/codebase/zulip_codebase_mirror +++ b/zulip/integrations/codebase/zulip_codebase_mirror @@ -293,8 +293,7 @@ def check_permissions() -> None: sys.stderr.write(str(e)) if __name__ == "__main__": - if not isinstance(config.RESUME_FILE, str): - sys.stderr.write("RESUME_FILE path not given; refusing to continue") + assert isinstance(config.RESUME_FILE, str), "RESUME_FILE path not given; refusing to continue" check_permissions() if config.LOG_FILE: logging.basicConfig(filename=config.LOG_FILE, level=logging.WARNING) diff --git a/zulip/integrations/git/zulip_git_config.py b/zulip/integrations/git/zulip_git_config.py index 15a9383..6000a09 100644 --- a/zulip/integrations/git/zulip_git_config.py +++ b/zulip/integrations/git/zulip_git_config.py @@ -41,7 +41,7 @@ def format_commit_message(author: Text, subject: Text, commit_id: Text) -> Text: ## If properly installed, the Zulip API should be in your import ## path, but if not, set a custom path below -ZULIP_API_PATH = None +ZULIP_API_PATH: Optional[str] = None # Set this to your Zulip server's API URI ZULIP_SITE = "https://zulip.example.com" diff --git a/zulip/integrations/perforce/zulip_perforce_config.py b/zulip/integrations/perforce/zulip_perforce_config.py index cb02ab8..2e2aa2f 100644 --- a/zulip/integrations/perforce/zulip_perforce_config.py +++ b/zulip/integrations/perforce/zulip_perforce_config.py @@ -12,7 +12,7 @@ ZULIP_IGNORE_MISSING_STREAM = False # Set this to point at a p4web installation to get changelist IDs as links # P4_WEB = "https://p4web.example.com" -P4_WEB = None +P4_WEB: Optional[str] = None # commit_notice_destination() lets you customize where commit notices # are sent to with the full power of a Python function. @@ -45,4 +45,4 @@ def commit_notice_destination(path: Text, changelist: int) -> Optional[Dict[Text ## If properly installed, the Zulip API should be in your import ## path, but if not, set a custom path below -ZULIP_API_PATH = None +ZULIP_API_PATH: Optional[str] = None diff --git a/zulip/integrations/svn/zulip_svn_config.py b/zulip/integrations/svn/zulip_svn_config.py index 804d5f0..4c9d94d 100644 --- a/zulip/integrations/svn/zulip_svn_config.py +++ b/zulip/integrations/svn/zulip_svn_config.py @@ -29,7 +29,7 @@ def commit_notice_destination(path: Text, commit: Text) -> Optional[Dict[Text, T ## If properly installed, the Zulip API should be in your import ## path, but if not, set a custom path below -ZULIP_API_PATH = None +ZULIP_API_PATH: Optional[str] = None # Set this to your Zulip server's API URI ZULIP_SITE = "https://zulip.example.com" diff --git a/zulip/integrations/trac/zulip_trac_config.py b/zulip/integrations/trac/zulip_trac_config.py index e4ddfda..4c1ec86 100644 --- a/zulip/integrations/trac/zulip_trac_config.py +++ b/zulip/integrations/trac/zulip_trac_config.py @@ -1,5 +1,7 @@ # See zulip_trac.py for installation and configuration instructions +from typing import Optional + # Change these constants to configure the plugin: ZULIP_USER = "trac-bot@example.com" ZULIP_API_KEY = "0123456789abcdef0123456789abcdef" @@ -23,7 +25,7 @@ TRAC_NOTIFY_FIELDS = ["description", "summary", "resolution", "comment", "owner" ## If properly installed, the Zulip API should be in your import ## path, but if not, set a custom path below -ZULIP_API_PATH = None +ZULIP_API_PATH: Optional[str] = None # Set this to your Zulip API server URI ZULIP_SITE = "https://zulip.example.com" diff --git a/zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py b/zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py index 4780835..4bbccd4 100644 --- a/zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py +++ b/zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py @@ -15,7 +15,7 @@ class VirtualFsHandler: def usage(self) -> str: return get_help() - def handle_message(self, message: Dict[str, str], bot_handler: BotHandler) -> None: + def handle_message(self, message: Dict[str, Any], bot_handler: BotHandler) -> None: command = message['content'] if command == "": command = "help" diff --git a/zulip_bots/zulip_bots/run.py b/zulip_bots/zulip_bots/run.py index 8d87d98..c67f591 100755 --- a/zulip_bots/zulip_bots/run.py +++ b/zulip_bots/zulip_bots/run.py @@ -83,7 +83,7 @@ def exit_gracefully_if_zulip_config_is_missing(config_file: Optional[str]) -> No sys.exit(1) -def exit_gracefully_if_bot_config_file_does_not_exist(bot_config_file: str) -> None: +def exit_gracefully_if_bot_config_file_does_not_exist(bot_config_file: Optional[str]) -> None: if bot_config_file is None: # This is a common case, just so succeed quietly. (Some # bots don't have third party configuration.)