From 0a854ddd2a6aecfc5b5afce262da41c812b1511e Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 14 Apr 2022 09:57:03 +0530 Subject: [PATCH] chore(frappe): Add typing hints for init methods --- frappe/__init__.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 37c282f04a..9d85f7adfa 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -25,7 +25,7 @@ import importlib import inspect import json import sys -from typing import TYPE_CHECKING, Dict, List, Union +from typing import TYPE_CHECKING, Dict, List, Optional, Union import click from werkzeug.local import Local, release_local @@ -80,7 +80,7 @@ class _dict(dict): return _dict(dict(self).copy()) -def _(msg, lang=None, context=None): +def _(msg: str, lang: Optional[str] = None, context: str = None) -> str: """Returns translated string in current lang, if exists. Usage: _('Change') @@ -317,14 +317,13 @@ def get_site_config(sites_path=None, site_path=None): return _dict(config) -def get_conf(site=None): +def get_conf(site: Optional[str] = None) -> _dict: if hasattr(local, "conf"): return local.conf - else: - # if no site, get from common_site_config.json - with init_site(site): - return local.conf + # if no site, get from common_site_config.json + with init_site(site): + return local.conf class init_site: