From 892e69b7adc7fa6ba9aed1a7a2d39e02a2e963d6 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 12 Nov 2019 17:53:01 -0800 Subject: [PATCH] settings: Turn on mypy checking. Signed-off-by: Anders Kaseorg --- mypy.ini | 6 ------ zproject/dev_settings.py | 2 +- zproject/settings.py | 17 +++++++++-------- zproject/test_settings.py | 3 +-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/mypy.ini b/mypy.ini index 062fa3ce89..0f1c96e44a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -40,12 +40,6 @@ warn_unreachable = True [mypy-conf] # For docs/conf.py. ignore_errors = True -[mypy-zproject.settings] -ignore_errors = True - -[mypy-zproject.test_settings] -ignore_errors = True - # zerver.tornado.autoreload is a slightly-patched piece of upstream Tornado. [mypy-zerver.tornado.autoreload] ignore_errors = True diff --git a/zproject/dev_settings.py b/zproject/dev_settings.py index 8c9285e977..2b34fa7ba4 100644 --- a/zproject/dev_settings.py +++ b/zproject/dev_settings.py @@ -150,7 +150,7 @@ if FAKE_LDAP_MODE: THUMBOR_URL = 'http://127.0.0.1:9995' THUMBNAIL_IMAGES = True -SEARCH_PILLS_ENABLED = os.getenv('SEARCH_PILLS_ENABLED', False) +SEARCH_PILLS_ENABLED = bool(os.getenv('SEARCH_PILLS_ENABLED', False)) BILLING_ENABLED = True diff --git a/zproject/settings.py b/zproject/settings.py index e7257dc97a..070804da00 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -14,6 +14,7 @@ from copy import deepcopy import os import time import sys +from typing import Any, Dict, List, Union from zerver.lib.db import TimeTrackingConnection import zerver.lib.logging_util @@ -147,7 +148,7 @@ ALLOWED_HOSTS += REALM_HOSTS.values() from django.template.loaders import app_directories class TwoFactorLoader(app_directories.Loader): - def get_dirs(self): + def get_dirs(self) -> List[str]: dirs = super().get_dirs() return [d for d in dirs if 'two_factor' in d] @@ -211,8 +212,8 @@ CORPORATE_ENABLED = 'corporate' in INSTALLED_APPS # Base URL of the Tornado server # We set it to None when running backend tests or populate_db. # We override the port number when running frontend tests. -TORNADO_PROCESSES = int(get_config('application_server', 'tornado_processes', 1)) -TORNADO_SERVER = 'http://127.0.0.1:9993' +TORNADO_PROCESSES = int(get_config('application_server', 'tornado_processes', '1')) +TORNADO_SERVER = 'http://127.0.0.1:9993' # type: Optional[str] RUNNING_INSIDE_TORNADO = False AUTORELOAD = DEBUG @@ -270,7 +271,7 @@ DATABASES = {"default": { 'OPTIONS': { 'connection_factory': TimeTrackingConnection }, -}} +}} # type: Dict[str, Dict[str, Any]] if DEVELOPMENT: LOCAL_DATABASE_PASSWORD = get_secret("local_database_password") @@ -449,7 +450,7 @@ INTERNAL_BOTS = [{'var_name': 'NOTIFICATION_BOT', 'name': 'Welcome Bot'}] # Bots that are created for each realm like the reminder-bot goes here. -REALM_INTERNAL_BOTS = [] +REALM_INTERNAL_BOTS = [] # type: List[Dict[str, str]] # These are realm-internal bots that may exist in some organizations, # so configure power the setting, but should not be auto-created at this time. DISABLED_REALM_INTERNAL_BOTS = [ @@ -545,7 +546,7 @@ WEBPACK_LOADER = { LOADERS = [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', -] +] # type: List[Union[str, Tuple[object, ...]]] if PRODUCTION: # Template caching is a significant performance win in production. LOADERS = [('django.template.loaders.cached.Loader', LOADERS)] @@ -564,7 +565,7 @@ base_template_engine_settings = { 'django.template.context_processors.i18n', ], }, -} +} # type: Dict[str, Any] default_template_engine_settings = deepcopy(base_template_engine_settings) default_template_engine_settings.update({ @@ -874,7 +875,7 @@ LOGGING = { 'propagate': False, }, } -} +} # type: Dict[str, Any] LOGIN_REDIRECT_URL = '/' diff --git a/zproject/test_settings.py b/zproject/test_settings.py index b3c866aac9..85c71cdde4 100644 --- a/zproject/test_settings.py +++ b/zproject/test_settings.py @@ -119,7 +119,7 @@ if not CASPER_TESTS: 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache' } - def set_loglevel(logger_name, level) -> None: + def set_loglevel(logger_name: str, level: str) -> None: LOGGING['loggers'].setdefault(logger_name, {})['level'] = level set_loglevel('zulip.requests', 'CRITICAL') set_loglevel('zulip.management', 'CRITICAL') @@ -215,6 +215,5 @@ SOCIAL_AUTH_SAML_ENABLED_IDPS = { "attr_username": "email", "attr_email": "email", "display_name": "Test IdP", - "display_icon": None, } }