From 908545768b4649ab2a9b681a76498d093fec1296 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 26 Nov 2023 08:09:52 -0600 Subject: [PATCH] Update pre-commit with newer tools (#724) --- .pre-commit-config.yaml | 48 +++++++++++++++++++++++----- aioesphomeapi/_frame_helper/base.py | 2 +- aioesphomeapi/_frame_helper/noise.py | 2 +- pyproject.toml | 5 +++ script/gen-protoc | 4 +-- setup.py | 8 ++--- 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 596558e..23a1620 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,41 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks +--- +exclude: '^aioesphomeapi/api.*$' repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-added-large-files +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files +- repo: https://github.com/asottile/pyupgrade + rev: v2.37.1 + hooks: + - id: pyupgrade + args: [--py37-plus] +- repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.1 + hooks: + - id: ruff + args: + - --fix +- repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.11.0 + hooks: + - id: black + args: + - --quiet + files: ^((aioesphomeapi|tests)/.+)?[^/]+\.py$ +- repo: https://github.com/cdce8p/python-typing-update + rev: v0.6.0 + hooks: + - id: python-typing-update + stages: [manual] + args: + - --py39-plus + - --force + - --keep-updates + files: ^(aioesphomeapi)/.+\.py$ diff --git a/aioesphomeapi/_frame_helper/base.py b/aioesphomeapi/_frame_helper/base.py index 194bf1c..8ed4392 100644 --- a/aioesphomeapi/_frame_helper/base.py +++ b/aioesphomeapi/_frame_helper/base.py @@ -42,7 +42,7 @@ class APIFrameHelper: def __init__( self, - connection: "APIConnection", + connection: APIConnection, client_info: str, log_name: str, ) -> None: diff --git a/aioesphomeapi/_frame_helper/noise.py b/aioesphomeapi/_frame_helper/noise.py index efe59d5..8622ff7 100644 --- a/aioesphomeapi/_frame_helper/noise.py +++ b/aioesphomeapi/_frame_helper/noise.py @@ -83,7 +83,7 @@ class APINoiseFrameHelper(APIFrameHelper): def __init__( self, - connection: "APIConnection", + connection: APIConnection, noise_psk: str, expected_name: str | None, client_info: str, diff --git a/pyproject.toml b/pyproject.toml index f01be14..1126d93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,5 +30,10 @@ disable = [ "too-many-lines", ] +[tool.ruff] +ignore = [ + "E721", # We want type() check for protobuf messages +] + [build-system] requires = ['setuptools>=65.4.1', 'wheel', 'Cython>=3.0.2'] diff --git a/script/gen-protoc b/script/gen-protoc index 8e767f2..013eb37 100755 --- a/script/gen-protoc +++ b/script/gen-protoc @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -from subprocess import check_call -from pathlib import Path import os +from pathlib import Path +from subprocess import check_call root_dir = Path(__file__).absolute().parent.parent os.chdir(root_dir) diff --git a/setup.py b/setup.py index 6e43e3d..124e64f 100644 --- a/setup.py +++ b/setup.py @@ -23,11 +23,11 @@ PROJECT_EMAIL = "esphome@nabucasa.com" PROJECT_GITHUB_USERNAME = "esphome" PROJECT_GITHUB_REPOSITORY = "aioesphomeapi" -PYPI_URL = "https://pypi.python.org/pypi/{}".format(PROJECT_PACKAGE_NAME) -GITHUB_PATH = "{}/{}".format(PROJECT_GITHUB_USERNAME, PROJECT_GITHUB_REPOSITORY) -GITHUB_URL = "https://github.com/{}".format(GITHUB_PATH) +PYPI_URL = f"https://pypi.python.org/pypi/{PROJECT_PACKAGE_NAME}" +GITHUB_PATH = f"{PROJECT_GITHUB_USERNAME}/{PROJECT_GITHUB_REPOSITORY}" +GITHUB_URL = f"https://github.com/{GITHUB_PATH}" -DOWNLOAD_URL = "{}/archive/{}.zip".format(GITHUB_URL, VERSION) +DOWNLOAD_URL = f"{GITHUB_URL}/archive/{VERSION}.zip" MODULES_TO_CYTHONIZE = [ "aioesphomeapi/client_callbacks.py",