-
Notifications
You must be signed in to change notification settings - Fork 271
Add type hints #74
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
Add type hints #74
Conversation
eth_abi/utils/padding.py
Outdated
@@ -4,23 +4,23 @@ | |||
|
|||
|
|||
@curry | |||
def zpad(value, length): | |||
def zpad(value:str, length:int) -> 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.
Can you add spaces after the :
for style consistency.
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.
Oh sure. I was going to lint it after I was done with it. I will do that before asking for a review its still WIP. 😄
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.
Also, I'm pretty sure that this function, and the others for which type annotations were added, accept bytes
values and not str
.
eth_abi/utils/numeric.py
Outdated
@@ -46,7 +47,7 @@ def compute_signed_fixed_bounds(num_bits, frac_places): | |||
return lower, upper | |||
|
|||
|
|||
def compute_unsigned_real_bounds(num_high_bits, num_low_bits): | |||
def compute_unsigned_real_bounds(num_high_bits: int, num_low_bits: int) -> Tuple[int, int]: |
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.
Both compute_unsigned_real_bounds
and compute_signed_real_bounds
should return Tuple[float, float]
if I'm not mistaken.
eth_abi/utils/numeric.py
Outdated
@@ -66,7 +67,7 @@ def compute_signed_real_bounds(num_high_bits, num_low_bits): | |||
) | |||
|
|||
|
|||
def quantize_value(value, decimal_bit_size): | |||
def quantize_value(value: int, decimal_bit_size: int) -> decimal.Decimal: |
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.
This function is doing rounding on a value which is likely to have a fractional component. So it probably won't ever get an int
as an input for value
. I'm pretty sure value's type should be Union[float, decimal.Decimal]
or something like that.
tox.ini
Outdated
-r{toxinidir}/requirements-dev.txt | ||
basepython= | ||
py35: python3.5 | ||
py36: python3.6 | ||
pypy3: pypy3 | ||
passenv=PYTEST_ADDOPTS |
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.
This line shouldn't have been removed.
eth_abi/utils/padding.py
Outdated
@@ -4,23 +4,23 @@ | |||
|
|||
|
|||
@curry | |||
def zpad(value, length): | |||
def zpad(value:str, length:int) -> 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.
Also, I'm pretty sure that this function, and the others for which type annotations were added, accept bytes
values and not str
.
* bump versions in dependencies and ci builds * move tox to [dev] per issue ethereum#34 * move RTD deps pointer into .readthedocs.yml * unpin flake8 add flake8-bugbear to lint deps
* bump versions in dependencies and ci builds * move tox to [dev] per issue ethereum#34 * move RTD deps pointer into .readthedocs.yml * unpin flake8 add flake8-bugbear to lint deps
Also tox.ini: Add mypy to the CI
Closes: #33
Sorry for taking so long to open this PR. I was busy with exams and GSoC preparations.
I will keep updating this.
What was wrong?
Type hints were not present
How was it fixed?
Mypy was added to the CI and type hints added to the packages
Cute Animal Picture