Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mtchuikov
Copy link

No description provided.

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!')
Copy link
Collaborator

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):
Copy link
Collaborator

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):
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants