Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32#3# Copyright (c) 2022-present The Bitcoin Core developers4# Distributed under the MIT software license, see the accompanying5# file COPYING or http://www.opensource.org/licenses/mit-license.php.7"""8Check for specified mypy warnings in python files.9"""11import os12from pathlib import Path13import subprocess15from importlib.metadata import metadata, PackageNotFoundError17# Customize mypy cache dir via environment variable18cache_dir = Path(__file__).parent.parent / ".mypy_cache"19os.environ["MYPY_CACHE_DIR"] = str(cache_dir)21DEPS = ['lief', 'mypy', 'pyzmq']23# Only .py files in test/functional and contrib/(devtools|guix) have type annotations24# enforced.25MYPY_FILES_ARGS = ['git', 'ls-files', 'test/functional/*.py', 'contrib/devtools/*.py', 'contrib/guix/*.py']28def check_dependencies():29for dep in DEPS:30try:31metadata(dep)32except PackageNotFoundError:33print(f"Skipping Python linting since {dep} is not installed.")34exit(0)37def main():38check_dependencies()40mypy_files = subprocess.check_output(MYPY_FILES_ARGS, text=True).splitlines()41mypy_args = ['mypy', '--show-error-codes'] + mypy_files43try:44subprocess.check_call(mypy_args)45except subprocess.CalledProcessError:46exit(1)49if __name__ == "__main__":50main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.