mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
script: replace deprecated pkg_resources with importlib.metadata
in our python linter: ``` ./test/lint/lint-python.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources ``` The importlib.metadata library was added in Python 3.8, which is currently our minimum-supported Python version. For more details about importlib.metadata, see https://docs.python.org/3/library/importlib.metadata.html
This commit is contained in:
parent
c9273f68f6
commit
6c008a2006
1 changed files with 6 additions and 4 deletions
|
@ -9,10 +9,12 @@ Check for specified flake8 and mypy warnings in python files.
|
|||
"""
|
||||
|
||||
import os
|
||||
import pkg_resources
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from importlib.metadata import metadata, PackageNotFoundError
|
||||
|
||||
|
||||
DEPS = ['flake8', 'lief', 'mypy', 'pyzmq']
|
||||
MYPY_CACHE_DIR = f"{os.getenv('BASE_ROOT_DIR', '')}/test/.mypy_cache"
|
||||
|
||||
|
@ -99,10 +101,10 @@ ENABLED = (
|
|||
|
||||
|
||||
def check_dependencies():
|
||||
working_set = {pkg.key for pkg in pkg_resources.working_set}
|
||||
|
||||
for dep in DEPS:
|
||||
if dep not in working_set:
|
||||
try:
|
||||
metadata(dep)
|
||||
except PackageNotFoundError:
|
||||
print(f"Skipping Python linting since {dep} is not installed.")
|
||||
exit(0)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue