mirror of
				https://github.com/home-assistant/core.git
				synced 2025-11-03 16:09:36 +00:00 
			
		
		
		
	Migrate legacy typehints in core to PEP-526 (#26403)
* Migrate legacy typehints in core to PEP-526 * Fix one type
This commit is contained in:
		
				
					committed by
					
						
						Paulus Schoutsen
					
				
			
			
				
	
			
			
			
						parent
						
							2dc90be94f
						
					
				
				
					commit
					2f0eb07624
				
			@@ -21,11 +21,11 @@ REQUIREMENTS = ("colorlog==4.0.2",)
 | 
			
		||||
 | 
			
		||||
_LOGGER = logging.getLogger(__name__)
 | 
			
		||||
# pylint: disable=protected-access
 | 
			
		||||
MOCKS = {
 | 
			
		||||
MOCKS: Dict[str, Tuple[str, Callable]] = {
 | 
			
		||||
    "load": ("homeassistant.util.yaml.loader.load_yaml", yaml_loader.load_yaml),
 | 
			
		||||
    "load*": ("homeassistant.config.load_yaml", yaml_loader.load_yaml),
 | 
			
		||||
    "secrets": ("homeassistant.util.yaml.loader.secret_yaml", yaml_loader.secret_yaml),
 | 
			
		||||
}  # type: Dict[str, Tuple[str, Callable]]
 | 
			
		||||
}
 | 
			
		||||
SILENCE = ("homeassistant.scripts.check_config.yaml_loader.clear_secret_cache",)
 | 
			
		||||
 | 
			
		||||
PATCHES: Dict[str, Any] = {}
 | 
			
		||||
@@ -82,7 +82,7 @@ def run(script_args: List) -> int:
 | 
			
		||||
 | 
			
		||||
    res = check(config_dir, args.secrets)
 | 
			
		||||
 | 
			
		||||
    domain_info = []  # type: List[str]
 | 
			
		||||
    domain_info: List[str] = []
 | 
			
		||||
    if args.info:
 | 
			
		||||
        domain_info = args.info.split(",")
 | 
			
		||||
 | 
			
		||||
@@ -122,7 +122,7 @@ def run(script_args: List) -> int:
 | 
			
		||||
                dump_dict(res["components"].get(domain, None))
 | 
			
		||||
 | 
			
		||||
    if args.secrets:
 | 
			
		||||
        flatsecret = {}  # type: Dict[str, str]
 | 
			
		||||
        flatsecret: Dict[str, str] = {}
 | 
			
		||||
 | 
			
		||||
        for sfn, sdict in res["secret_cache"].items():
 | 
			
		||||
            sss = []
 | 
			
		||||
@@ -153,13 +153,13 @@ def run(script_args: List) -> int:
 | 
			
		||||
def check(config_dir, secrets=False):
 | 
			
		||||
    """Perform a check by mocking hass load functions."""
 | 
			
		||||
    logging.getLogger("homeassistant.loader").setLevel(logging.CRITICAL)
 | 
			
		||||
    res = {
 | 
			
		||||
    res: Dict[str, Any] = {
 | 
			
		||||
        "yaml_files": OrderedDict(),  # yaml_files loaded
 | 
			
		||||
        "secrets": OrderedDict(),  # secret cache and secrets loaded
 | 
			
		||||
        "except": OrderedDict(),  # exceptions raised (with config)
 | 
			
		||||
        #'components' is a HomeAssistantConfig  # noqa: E265
 | 
			
		||||
        "secret_cache": None,
 | 
			
		||||
    }  # type: Dict[str, Any]
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # pylint: disable=possibly-unused-variable
 | 
			
		||||
    def mock_load(filename):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user