From 5ff61b6d5c7152fd258cf92529b68b84978b89f5 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Thu, 20 Nov 2025 10:10:33 +0000 Subject: [PATCH] feat(setup): add optional pyright installation and create type-check script --- pyproject.toml | 29 ++++++++++++++++++++++------- scripts/check | 14 ++++++++++++++ scripts/setup | 9 +++++++++ scripts/type-check | 17 +++++++++++++++++ 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100755 scripts/check create mode 100755 scripts/type-check diff --git a/pyproject.toml b/pyproject.toml index 2c19afa..35c3277 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,12 +4,27 @@ build-backend = "setuptools.build_meta" [project] name = "tibber_prices" -version = "0.0.0" # Version is managed in manifest.json only +version = "0.0.0" # Version is managed in manifest.json only requires-python = ">=3.13" [tool.setuptools] packages = ["custom_components.tibber_prices"] +[tool.pyright] +include = ["custom_components/tibber_prices"] +exclude = [ + "**/node_modules", + "**/__pycache__", + "**/.git", + "**/.github", + "**/docs", + "**/venv", + "**/.venv", +] +venvPath = "." +venv = ".venv" +typeCheckingMode = "basic" + [tool.ruff] # Based on https://github.com/home-assistant/core/blob/dev/pyproject.toml target-version = "py313" @@ -18,12 +33,12 @@ line-length = 120 [tool.ruff.lint] select = ["ALL"] ignore = [ -# "ANN101", # Missing type annotation for `self` in method - "ANN401", # Dynamically typed expressions (typing.Any) are disallowed - "D203", # no-blank-line-before-class (incompatible with formatter) - "D212", # multi-line-summary-first-line (incompatible with formatter) - "COM812", # incompatible with formatter - "ISC001", # incompatible with formatter + # "ANN101", # Missing type annotation for `self` in method + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed + "D203", # no-blank-line-before-class (incompatible with formatter) + "D212", # multi-line-summary-first-line (incompatible with formatter) + "COM812", # incompatible with formatter + "ISC001", # incompatible with formatter ] [tool.ruff.lint.flake8-pytest-style] diff --git a/scripts/check b/scripts/check new file mode 100755 index 0000000..22cf628 --- /dev/null +++ b/scripts/check @@ -0,0 +1,14 @@ +#!/bin/sh + +# script/check: Run linting and type checking tools together + +set -e + +cd "$(dirname "$0")/.." + +if [ -z "$VIRTUAL_ENV" ]; then + . "$HOME/.venv/bin/activate" +fi + +scripts/type-check +scripts/lint-check diff --git a/scripts/setup b/scripts/setup index 603c575..ef534ea 100755 --- a/scripts/setup +++ b/scripts/setup @@ -6,6 +6,15 @@ set -e cd "$(dirname "$0")/.." +# Install optional pyright for type checking +if command -v npm >/dev/null 2>&1; then + echo "==> Installing pyright for type checking..." + npm install -g pyright 2>/dev/null || { + echo " ⚠️ Warning: pyright installation failed (optional)" + echo " ℹ️ You can install it manually: npm install -g pyright" + } +fi + # Install optional release note backend: GitHub Copilot CLI (AI-powered) if command -v npm >/dev/null 2>&1; then echo "==> Installing GitHub Copilot CLI for AI-powered release notes..." diff --git a/scripts/type-check b/scripts/type-check new file mode 100755 index 0000000..792ecdc --- /dev/null +++ b/scripts/type-check @@ -0,0 +1,17 @@ +#!/bin/sh + +# script/type-check: Run type checking tools + +set -e + +cd "$(dirname "$0")/.." + +if [ -z "$VIRTUAL_ENV" ]; then + . "$HOME/.venv/bin/activate" +fi + +echo "==> Running type checking tools..." + +pyright + +echo "==> Type checking completed."