-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update utils.py #72
base: master
Are you sure you want to change the base?
Update utils.py #72
Conversation
return int(strVal, 16) if type(strVal) == str and strVal.startswith('0x') else int(strVal, 10) | ||
def hex_to_int(value: str) -> int: | ||
if not (isinstance(value, str) and len(value) > 0): | ||
raise TypeError('The value must not be an empty str!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still want to allow None
as a valid input (this would happen when creating a test block_event
or transaction_event
without having to specify every field)
assert_key_in_dict(dict, key) | ||
assert isinstance(dict[key], enum), f'{key} must be valid enum value' | ||
@is_valid_key | ||
def is_valid_string(dict: dict, key: int or str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets keep the function names the same (i.e. assert_enum_value_in_dict
and assert_non_empty_string_in_dict
) as they are used in other places as well
dict[key]) > 0, f'{key} must be non-empty string' | ||
def is_valid_key(func: callable): | ||
|
||
def wrap(dict: dict, key: str or int, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the key
type should always be str
No description provided.