ethereum / ethereum/py_ecc

Cleanup isinstance checks for integers to disallow booleans

Open
#30 0 comments 0 reactions 0 assignees View on GitHub
Good First Issue
Dominant language
Python
Stars
231
Forks
88
PR merge metrics
No merged PRs in 30d

Description

### What is wrong?

Lots of places in the codebase do assertions like `isinstance(v, int)` to check that something is an integer. Since python considers `True` and `False` to be integer types these checks won't disallow passing in a `bool` value.

### How can it be fixed

Probably need to add a single utility and make use of it everywhere that we do these checks.

```python
def assert_strictly_integer(v):
assert isinstance(v, int) and not isinstance(v, bool)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.