Re: [libgpiod][PATCH 9/9] bindings: python: update linter configuration

Vincent Fazio
2026-04-02T15:55:21Z

On Thu, Apr 2, 2026 at 9:37 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
> Ruff checks work fine but I'm seeing this with mypy:
>
> $ mypy
> build_tests.py:22: error: Library stubs not installed for "setuptools"
> [import-untyped]
> build_tests.py:23: error: Library stubs not installed for
> "setuptools.command.build_ext" [import-untyped]
> build_tests.py:23: note: Hint: "python3 -m pip install types-setuptools"
> build_tests.py:23: note: (or run "mypy --install-types" to install all
> missing stub packages)
> build_tests.py:23: note: See
> https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
> setup.py:10: error: Library stubs not installed for "setuptools"
> [import-untyped]
> setup.py:11: error: Library stubs not installed for
> "setuptools.command.build_ext" [import-untyped]
> setup.py:12: error: Library stubs not installed for
> "setuptools.command.sdist" [import-untyped]
> setup.py:13: error: Library stubs not installed for
> "setuptools.errors" [import-untyped]
> Found 6 errors in 2 files (checked 45 source files)
>
> I'm using mypy v1.20.0. Is this something with my environment?

Yes, slightly. I guess maybe I didn't state it explicitly, but when I
added patch 8, I included a list of required dependencies for type
checking and called out the group in documentaiton:
https://lore.kernel.org/linux-gpio/20260401001459.19159-8-vfazio@gmail.com/T/#u

If you're running mypy from within a virtual environment, you'll need
to make sure that the dependencies in that group are installed for a
clean check and can use the dependency group to help with that.

If you're running mypy from the system level and outside of a virtual
environment, you will have to install the distribution packages that
provide the typing information.

My typical workflow for ensuring that linter checks pass:
* cd bindings/python
* python3 -m venv venv
* .venv/bin/activate
* pip install -U pip
* (now) pip install --group lint
* mypy --strict; ruff format; ruff check

Some repositories try to implement these checks as part of pre-commit
hooks but I wasn't sure if we wanted to go so far as requiring these
checks