lint: modernise lint tooling #34547

pull willcl-ark wants to merge 9 commits into bitcoin:master from willcl-ark:modernise-linter changing 9 files +95 −127
  1. willcl-ark commented at 10:25 am on February 10, 2026: member

    Modernise our lint tooling by:

    - Replacing pyenv + pip with uv for better Python environment and dependency management - Replacing mypy with https://github.com/astral-sh/ty - Replacing the 01_install.sh runtime install script with COPY –from multi-stage Docker image imports for uv, ruff, shellcheck, mlc, and ty - Moving ruff lint rules from hardcoded Rust array (in lint_py.rs) into a top-level ruff.toml, and add ty.toml for the type checker - Extracting all remaining pip dependencies into dedicated ci/lint/requirements.txt

    Extra rationale:

    COPY --from pulls pre-built binaries from upstream images instead of compiling/downloading at runtime. Containerfile layer optimisations reduce rebuild frequency further.

    ty is significantly faster/more modern/maintained than mypy, and configured declaratively.

    Adding root-level [ty|ruff].toml config files means contributors can easily run ty check or ruff check locally without running the full linter, along with being accessible to other tooling (similarly for requriements.txt).

    Pinning tool versions in the dockerfile makes it more excplicit and easier to find.

    The tradeoff we make here is that there is no longer a bare install script to install tooling on a local machine. However I think this is OK, as it currently only works for apt-based OSes anyway, and I don’t think running the linter outside of the container is such a valuable use-case as it is with some of the other CI jobs.

    Further work can drop individual rules from ty.toml fixing up the infringing code as necessary.

    I can split this up if wanted, but IMO it makes sense to do it altogether.

  2. DrahtBot added the label Tests on Feb 10, 2026
  3. DrahtBot commented at 10:25 am on February 10, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34550 (guix: update time-machine to bf0614854d0232d9181a92a6d7768ca9a62deb84 by fanquake)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. fanquake commented at 10:39 am on February 10, 2026: member

    Tried running this locally, but it currently fails on arm64, because there is no arm64 variant for becheran/mlc:

    0Error: choosing an image from manifest list docker://becheran/mlc:latest: no image found in image index for architecture "arm64", variant "v8", OS "linux"
    
  5. willcl-ark marked this as a draft on Feb 10, 2026
  6. in ci/lint_imagefile:15 in b63444e4d1 outdated
    11+ENV LC_ALL=C
    12+ENV PATH="/python_env/bin:${PATH}"
    13+ENV VIRTUAL_ENV="/python_env"
    14+
    15+COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
    16+COPY --from=ghcr.io/astral-sh/ruff:0.14.4 /ruff /bin/
    


    maflcko commented at 10:58 am on February 10, 2026:
    Is there any value in having ruff separate? It would appear more consistent to install it next to the other ci/lint/requirements.txt (lief, etc)

    willcl-ark commented at 12:16 pm on February 10, 2026:

    The main advantage is that the COPY --from instructions are standalone layers and are not invalidated when things below change (they are just “replayed” over the top). The more tools we can install from them, the better (usually).

    No strong opinion here, as the end result is the same. But IMO it’s better practice to install from layers like I have it.


    maflcko commented at 12:53 pm on February 10, 2026:

    Sure, makes sense to use COPY –from to keep the layers in the cache.

    I guess the main question is whether we want to force all devs to use the docker image. I think it should be fine for devs to pick pip and then install ci/lint/requirements.txt and get all the stuff they want. But no strong opinion, I rely on the GHA-ci for the lint anyway.

  7. in ci/lint_imagefile:29 in b63444e4d1 outdated
    29+  uv python install && \
    30   echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \
    31-  chmod 755 /entrypoint.sh && \
    32   rm -rf /var/lib/apt/lists/*
    33 
    34+COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh
    


    maflcko commented at 10:59 am on February 10, 2026:
    This seems to conflict with #34427. Maybe that should be merged/closed first?

    willcl-ark commented at 12:59 pm on February 10, 2026:
    Agree. I’ve acked that PR already, and would be happy to rebase this on it (or see it closed) – no strong opinion either way really.
  8. willcl-ark force-pushed on Feb 10, 2026
  9. willcl-ark commented at 12:17 pm on February 10, 2026: member

    Tried running this locally, but it currently fails on arm64, because there is no arm64 variant for becheran/mlc:

    0Error: choosing an image from manifest list docker://becheran/mlc:latest: no image found in image index for architecture "arm64", variant "v8", OS "linux"
    

    This should be fixed in the latest push. We currently (and still here) use an x86_64 MLC binary, but this works in an arm64 container (e.g on Mac) because the Rosetta emulation is passed in/used inside the container.

    I keep this behaviour for now, but ideally MLC woudl start publishing multi-platform docker images.

  10. willcl-ark marked this as ready for review on Feb 10, 2026
  11. DrahtBot added the label Needs rebase on Feb 12, 2026
  12. lint: install uv from docker and use
    https://docs.astral.sh/uv/
    
    Install python in the linter using uv and a venv.
    This is faster and more simple than building pyenv.
    7beabef7e5
  13. lint: install ruff from docker image
    Align with uv tool installation method.
    e105b26c57
  14. lint: install shellcheck from docker image 8891971deb
  15. lint: add ruff.toml 5c76a94e4b
  16. lint: add ty.toml
    Add ty typechecker configuration file.
    
    Includes all needed rules to have `ty` pass on selected files in current
    codebase. This is pretty much all useful rules, but we will remove
    them systematically in follow-ups.
    2f357d852f
  17. lint: use ruff.toml in linter d56d91fc29
  18. lint: install ty typechecker from docker and use
    Remove mypy and switch to `ty` for typechecking.
    
    https://docs.astral.sh/ty/
    https://astral.sh/blog/ty
    
    It's faster and more maintained than mypy. Comes with better editor
    integrations, a language server and is written in rust (tm).
    
    As features are added we may be able to replace vulture with ty too.
    
    Install from docker image as per `uv` and `ruff`.
    3edd04b4c0
  19. lint: move remaining install to dockerfile
    Note: we keep MLC install via curl binary download. This is currently
    hardcoded to an x86_64 binary, but this seems to run fine in an arm64
    container (on MacOS), as Rosetta support is passed in (on docker and
    podman) to take care of exactly this.
    
    If upstream MLC start providing a multi-image dockerfile then this
    dependency could be made it's own `FROM --...` layer as most of the
    others are.
    ca006a4357
  20. lint: use requirements.txt 002b15b6a3
  21. willcl-ark force-pushed on Feb 12, 2026
  22. DrahtBot removed the label Needs rebase on Feb 12, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-17 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me