This is an automated email from the ASF dual-hosted git repository.
johnbodley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 53b58ed [mypy] Enforcing typing for translations (#9800)
53b58ed is described below
commit 53b58edd6ff759c87ea177b157206e1024c7629a
Author: John Bodley <[email protected]>
AuthorDate: Sat May 16 23:55:49 2020 -0700
[mypy] Enforcing typing for translations (#9800)
Co-authored-by: John Bodley <[email protected]>
---
setup.cfg | 2 +-
superset/translations/utils.py | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index e571796..87d49f1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,7 +53,7 @@ order_by_type = false
ignore_missing_imports = true
no_implicit_optional = true
-[mypy-superset.bin.*,superset.charts.*,superset.datasets.*,superset.dashboards.*,superset.commands.*,superset.common.*,superset.dao.*,superset.db_engine_specs.*,superset.db_engines.*,superset.examples.*,superset.migrations.*,superset.queries.*,superset.security.*,superset.sql_validators.*,superset.tasks.*]
+[mypy-superset.bin.*,superset.charts.*,superset.datasets.*,superset.dashboards.*,superset.commands.*,superset.common.*,superset.dao.*,superset.db_engine_specs.*,superset.db_engines.*,superset.examples.*,superset.migrations.*,superset.queries.*,superset.security.*,superset.sql_validators.*,superset.tasks.*,superset.translations.*]
check_untyped_defs = true
disallow_untyped_calls = true
disallow_untyped_defs = true
diff --git a/superset/translations/utils.py b/superset/translations/utils.py
index bfb12bb..25a698f 100644
--- a/superset/translations/utils.py
+++ b/superset/translations/utils.py
@@ -16,15 +16,15 @@
# under the License.
import json
import os
-from typing import Any, Dict
+from typing import Any, Dict, Optional
# Global caching for JSON language packs
-ALL_LANGUAGE_PACKS: Dict[str, Dict[Any, Any]] = {"en": {}}
+ALL_LANGUAGE_PACKS: Dict[str, Dict[str, Any]] = {"en": {}}
DIR = os.path.dirname(os.path.abspath(__file__))
-def get_language_pack(locale):
+def get_language_pack(locale: str) -> Optional[Dict[str, Any]]:
"""Get/cache a language pack
Returns the langugage pack from cache if it exists, caches otherwise
@@ -38,7 +38,7 @@ def get_language_pack(locale):
try:
with open(filename, encoding="utf8") as f:
pack = json.load(f)
- ALL_LANGUAGE_PACKS[locale] = pack
+ ALL_LANGUAGE_PACKS[locale] = pack or {}
except Exception: # pylint: disable=broad-except
# Assuming english, client side falls back on english
pass