Skip to content

Improve mypy check in make lint #4628

@danceratopz

Description

@danceratopz

Currently, the mypy check in the Makefile lint target runs on the eth2spec packages as defined by:

MYPY_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), -p eth2spec.$S)

While working on #4627 I temporarily broke the mypy check and thefore realized it can be improved:

@$(PYTHON_VENV) -m mypy --config-file $(MYPY_CONFIG) $(MYPY_SCOPE)

Background: The work in #4627 moves Python project management to uv and, as such, uv sync --all-extras becomes the method to install all the project's dependencies. This also installs eth2spec in "editable" mode, whereas before, it was directly installed by the Makefile in the virtual env.

Improvement: We should typecheck our source by specifying the path to the eth2spec source tree itself (instead of as a package via -p). Indeed, with the above, some files are not checked, as they are outside the scope of the packages defined in MYPY_SCOPE.

Here are some options:

  1. Check everything under tests/ (2783 errors).
uv run mypy --explicit-package-bases tests/
  1. Check everything under tests/core/pyspec/eth2spec/, including tests/core/pyspec/eth2spec/test/ (2390 errors).
uv run mypy --explicit-package-bases tests/core/pyspec/eth2spec/
  1. Check tests/core/pyspec/eth2spec/, but exclude tests/core/pyspec/eth2spec/test/ (90 errors).
uv run mypy --explicit-package-bases tests/core/pyspec/eth2spec/ --exclude tests/core/pyspec/eth2spec/test/
  1. There's also this which includes tests/infra, tests/generators/, ... but excludes tests/core/pyspec/eth2spec/test/ (505 errors).
uv run mypy --explicit-package-bases tests/ --exclude tests/core/pyspec/eth2spec/test/

As a tester, I like to treat test code is a first class citizen 🙂 and would go with 0. or 1., but 2. would be an improvement and a good start for the spec!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions