chore(frappe): Add typing hints for init methods

This commit is contained in:
Gavin D'souza 2022-04-14 09:57:03 +05:30
parent d7abbe0e10
commit 0a854ddd2a

View file

@ -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: