Skip to content

Conversation

palash25
Copy link
Contributor

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

Cute animal picture

@palash25 palash25 changed the title [WIP] Add type hints Add type hints May 31, 2018
@palash25 palash25 changed the title Add type hints [WIP] Add type hints May 31, 2018
@pipermerriam pipermerriam requested a review from davesque May 31, 2018 15:49
@@ -4,23 +4,23 @@


@curry
def zpad(value, length):
def zpad(value:str, length:int) -> str:
Copy link
Member

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.

Copy link
Contributor Author

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. 😄

Copy link
Contributor

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.

@@ -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]:
Copy link
Contributor

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.

@@ -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:
Copy link
Contributor

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
Copy link
Contributor

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.

@@ -4,23 +4,23 @@


@curry
def zpad(value, length):
def zpad(value:str, length:int) -> str:
Copy link
Contributor

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.

@davesque davesque merged commit 05963d5 into ethereum:master Aug 30, 2018
@palash25 palash25 changed the title [WIP] Add type hints Add type hints Feb 16, 2019
pacrob added a commit to pacrob/eth-abi that referenced this pull request Apr 14, 2023
* 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
pacrob added a commit to pacrob/eth-abi that referenced this pull request Dec 9, 2023
* 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
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.

Add type hints and mypy to CI
3 participants