Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Clarify verbose message
Browse files Browse the repository at this point in the history
  • Loading branch information
kennylajara committed Jun 21, 2021
1 parent 9c3d87b commit ad4e0a3
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions runup/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from abc import ABC, abstractmethod
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Union
import zipfile

# 3rd party
Expand Down Expand Up @@ -48,7 +48,7 @@ def missing_parameter(self, yaml_config:Dict[str, Any]) -> Optional[str]:
raise NotImplementedError()

@abstractmethod
def validate_parameters(self, yaml_config:Dict[str, Any], prefix:str='') -> Optional[str]:
def validate_parameters(self, search_area:Union[Dict[str, Any]], prefix:str='') -> Optional[str]:
"""Finds the parameters in YAML file not accepted by the interpreter"""
result:Optional[str] = None
valid_parameters:Dict[str] = self._valid_parameters.keys()
Expand All @@ -57,8 +57,9 @@ def validate_parameters(self, yaml_config:Dict[str, Any], prefix:str='') -> Opti
prefix = f'{prefix}.'
vInfo(self._verbose, f'New prefix `{prefix}`')

if type(yaml_config) == list:
for value in yaml_config:
if type(search_area) == list:
vInfo(self._verbose, f'`search_area` is a list')
for value in search_area:
vInfo(self._verbose, f'Testing parameter `{value}`')
full_key:str = ''
if f'{prefix}*' in valid_parameters:
Expand All @@ -71,16 +72,17 @@ def validate_parameters(self, yaml_config:Dict[str, Any], prefix:str='') -> Opti
if len(full_key) > 0:
vInfo(self._verbose, f'The value of parameter `{full_key}` is type {type(value)}')
if type(value) == self._valid_parameters[full_key]:
vInfo(self._verbose, f'`{type(value)}` is a valid type for `{full_key}`')
vInfo(self._verbose, f'`{type(value)}` is a valid type for parameter `{full_key}`')
else:
click.echo(f'`{value}` expected to be `{self._valid_parameters[full_key]}` but received `{type(value)}`')
click.echo(f'`{value}` expected to be type `{self._valid_parameters[full_key]}` but received `{type(value)}`')
return full_key
else:
vInfo(self._verbose, f'`{value}` is an invalid parameter')
vInfo(self._verbose, f'`{value}` is not a valid parameter')
return full_key

elif type(yaml_config) == dict:
for key, values in yaml_config.items():
elif type(search_area) == dict:
vInfo(self._verbose, f'`search_area` is a dict')
for key, values in search_area.items():

vInfo(self._verbose, f'Testing parameter `{key}`')
full_key:str = ''
Expand All @@ -92,7 +94,7 @@ def validate_parameters(self, yaml_config:Dict[str, Any], prefix:str='') -> Opti
vInfo(self._verbose, f'`{key}` has been found as `{prefix}{key}`')

if len(full_key) > 0:
vInfo(self._verbose, f'The value of the parameter `{prefix}{key}` is type {type(values)}')
vInfo(self._verbose, f'The value of parameter `{prefix}{key}` is type {type(values)}')
if type(values) == self._valid_parameters[full_key]:
vInfo(self._verbose, f'`{type(values)}` is a valid type for parameter `{prefix}{key}`')
else:
Expand All @@ -113,7 +115,7 @@ def validate_parameters(self, yaml_config:Dict[str, Any], prefix:str='') -> Opti
return full_key

else:
raise TypeError(f'`yaml_config` expected to be dict or list, `{type(yaml_config)}` received.')
raise TypeError(f'`search_area` expected to be dict or list, `{type(search_area)}` received.')

return None

Expand Down

2 comments on commit ad4e0a3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest-coverage-badge

Name Stmts Miss Cover
runup/init.py 0 0 100%
runup/cli.py 62 8 87%
runup/interpreter.py 213 41 81%
runup/runupdb.py 71 4 94%
runup/utils.py 32 0 100%
runup/version.py 3 0 100%
runup/yaml_parser.py 101 16 84%
TOTAL 482 69 86%

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest-coverage-badge

Name Stmts Miss Cover
runup/init.py 0 0 100%
runup/cli.py 62 8 87%
runup/interpreter.py 213 41 81%
runup/runupdb.py 71 4 94%
runup/utils.py 32 0 100%
runup/version.py 3 0 100%
runup/yaml_parser.py 101 16 84%
TOTAL 482 69 86%

Please sign in to comment.