ethereum / ethereum/execution-specs

feat(tooling,fw): improve type checking dev experience for pydantic models, e.g. `Storage`

Open
#1,515 1 comment 0 reactions 1 assignee Claimed by @danceratopz View on GitHub
A-test-config C-feat P-medium stale
Dominant language
Python
Stars
1.2k
Forks
505
Avg merge
2d 14h
Merged PRs (30d)
116

Description

This would reduce friction for test implementers unfamiliar with the EEST codebase.

Here's an example: If a `Storage` object is defined in test cases, `mypy` fails to detect that `int` is a valid type as a dict key or value. Currently, such `Storage` definitions need to be either marked as `type:ingore` or expliclitly cast to `HashInt`, e.g. `Storage(cast(Storage.StorageDictType, {1,1}))`.

Here, for example, type checking is manually disabled inline:
https://github.com/ethereum/execution-spec-tests/blob/2e1d3a0c7ec7a2f02fd7b9ad4900f79e323910f1/tests/cancun/eip4788_beacon_root/spec.py#L61

Otherwise, `mypy` returns the following two errors:
```
tests/cancun/eip4788_beacon_root/spec.py:61: error: Key expression in dictionary comprehension has incompatible type "int"; expected type "HashInt" [misc]
tests/cancun/eip4788_beacon_root/spec.py:61: error: Value expression in dictionary comprehension has incompatible type "int"; expected type "HashInt" [misc]
```

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.