From 57b48e6a3a3e7c8827bd18b60daa58bdd5d7361d Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Sat, 19 Apr 2025 23:58:39 +0800 Subject: [PATCH] chore(pre-commit): update pre-commit hooks --- .pre-commit-config.yaml | 23 ++++++++++------------- nvitop-exporter/setup.py | 20 +++++++++++--------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 15eda02..1d66dfe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,16 +27,25 @@ repos: - id: debug-statements - id: double-quote-string-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.4 + rev: v0.11.6 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format + args: [--exit-non-zero-on-format] - repo: https://github.com/codespell-project/codespell rev: v2.4.1 hooks: - id: codespell additional_dependencies: [".[toml]"] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.15.0 + hooks: + - id: mypy + exclude: | + (?x)( + ^nvitop-exporter/setup.py$ + ) - repo: local hooks: - id: pylint @@ -45,15 +54,3 @@ repos: language: system types: [python] require_serial: true - - repo: local - hooks: - - id: mypy - name: mypy - entry: mypy - language: system - types_or: [python, pyi] - require_serial: true - exclude: | - (?x)( - ^nvitop-exporter/setup.py$ - ) diff --git a/nvitop-exporter/setup.py b/nvitop-exporter/setup.py index 518c5a8..ea5a552 100755 --- a/nvitop-exporter/setup.py +++ b/nvitop-exporter/setup.py @@ -9,12 +9,13 @@ import re import sys from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path -from typing import TYPE_CHECKING, Generator +from typing import TYPE_CHECKING from setuptools import setup if TYPE_CHECKING: + from collections.abc import Generator from types import ModuleType @@ -61,11 +62,12 @@ def vcs_version(name: str, path: Path | str) -> Generator[ModuleType]: file.write(content) -with vcs_version( - name='nvitop_exporter.version', - path=(HERE / 'nvitop_exporter' / 'version.py'), -) as version: - setup( - name='nvitop-exporter', - version=version.__version__, - ) +if __name__ == '__main__': + with vcs_version( + name='nvitop_exporter.version', + path=(HERE / 'nvitop_exporter' / 'version.py'), + ) as version: + setup( + name='nvitop-exporter', + version=version.__version__, + )