Skip to content

Commit

Permalink
lint config
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Feb 14, 2024
1 parent 70ced97 commit 7cfecd0
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 58 deletions.
131 changes: 96 additions & 35 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,109 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
- repo: local
hooks:
- id: ruff-check
name: 🐶 Ruff Linter
language: system
types: [python]
entry: scripts/run-in-env.sh ruff check --fix
require_serial: true
stages: [commit, push, manual]
- id: ruff-format
name: 🐶 Ruff Formatter
language: system
types: [python]
entry: scripts/run-in-env.sh ruff format
require_serial: true
stages: [commit, push, manual]
- id: check-ast
name: 🐍 Check Python AST
language: system
types: [python]
entry: scripts/run-in-env.sh check-ast
- id: check-case-conflict
name: 🔠 Check for case conflicts
language: system
entry: scripts/run-in-env.sh check-case-conflict
- id: check-docstring-first
name: ℹ️ Check docstring is first
language: system
types: [python]
entry: scripts/run-in-env.sh check-docstring-first
- id: check-executables-have-shebangs
name: 🧐 Check that executables have shebangs
language: system
types: [text, executable]
entry: scripts/run-in-env.sh check-executables-have-shebangs
stages: [commit, push, manual]
- id: check-json
name: { Check JSON files
language: system
types: [json]
entry: scripts/run-in-env.sh check-json
files: ^(custom_components/mass)/.+\.json$
- id: check-yaml
name: { Check YAML files
language: system
types: [yaml]
entry: scripts/run-in-env.sh check-yaml
- id: check-merge-conflict
name: 💥 Check for merge conflicts
language: system
types: [text]
entry: scripts/run-in-env.sh check-merge-conflict
- id: check-symlinks
name: 🔗 Check for broken symlinks
language: system
types: [symlink]
entry: scripts/run-in-env.sh check-symlinks
- id: check-toml
name: ✅ Check TOML files
language: system
types: [toml]
entry: scripts/run-in-env.sh check-toml
- id: codespell
name: ✅ Check code for common misspellings
language: system
types: [text]
entry: scripts/run-in-env.sh codespell
- id: detect-private-key
name: 🕵️ Detect Private Keys
language: system
types: [text]
entry: scripts/run-in-env.sh detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
name: ⮐ Fix End of Files
language: system
types: [text]
entry: scripts/run-in-env.sh end-of-file-fixer
stages: [commit, push, manual]
- id: no-commit-to-branch
name: 🛑 Don't commit to main branch
language: system
entry: scripts/run-in-env.sh no-commit-to-branch
pass_filenames: false
always_run: true
args:
- --branch=main
- id: debug-statements
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.2.1'
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
args:
- --safe
- --quiet
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: []
exclude_types: [csv, json]
exclude: ^tests/fixtures/
additional_dependencies:
- tomli

- repo: local
hooks:
- id: pylint
name: pylint
entry: script/run-in-env.sh pylint -j 0
language: script
name: 🌟 Starring code with pylint
language: system
types: [python]
files: ^custom_components/mass/.+\.py$

# TODO: reinstate mypy after fixing the many issues
entry: scripts/run-in-env.sh pylint
- id: trailing-whitespace
name: ✄ Trim Trailing Whitespace
language: system
types: [text]
entry: scripts/run-in-env.sh trailing-whitespace-fixer
stages: [commit, push, manual]
###############################################
# TODO: enable mypy later
# - id: mypy
# name: mypy
# entry: script/run-in-env.sh mypy
# entry: scripts/run-in-env.sh mypy
# language: script
# types: [python]
# files: ^custom_components/mass/.+\.py$
# require_serial: true
# files: ^(custom_components/mass|pylint)/.+\.py$
1 change: 1 addition & 0 deletions custom_components/mass/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Music Assistant (music-assistant.github.io) integration."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions custom_components/mass/addon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide add-on management."""

from __future__ import annotations

from homeassistant.components.hassio import DOMAIN as HASSIO_DOMAIN
Expand Down
1 change: 1 addition & 0 deletions custom_components/mass/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants for Music Assistant Component."""

import logging

DOMAIN = "mass"
Expand Down
1 change: 1 addition & 0 deletions custom_components/mass/entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base entity model."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions custom_components/mass/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide integration helpers that are aware of the mass integration."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions custom_components/mass/media_browser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Media Source Implementation."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
7 changes: 4 additions & 3 deletions custom_components/mass/media_player.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MediaPlayer platform for Music Assistant integration."""

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -235,9 +236,9 @@ def extra_state_attributes(self) -> Mapping[str, Any]:
and queue.current_item.media_item
and queue.current_item.media_item.metadata
):
attrs[
ATTR_STREAM_TITLE
] = queue.current_item.media_item.metadata.description
attrs[ATTR_STREAM_TITLE] = (
queue.current_item.media_item.metadata.description
)
return attrs

async def async_on_update(self) -> None:
Expand Down
40 changes: 20 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ zip-safe = false
include = ["custom_components*"]

[tool.mypy]
check_untyped_defs = true
check_untyped_defs = true
disallow_any_generics = false # TEMPORARY DISABLED
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
follow_imports = "normal"
ignore_missing_imports = true
no_implicit_optional = true
no_implicit_reexport = true
platform = "linux"
python_version = "3.11"
strict_optional = true
warn_incomplete_stub = true
warn_no_return = true
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
follow_imports = "normal"
ignore_missing_imports = true
no_implicit_optional = true
no_implicit_reexport = true
platform = "linux"
python_version = "3.11"
strict_optional = true
warn_incomplete_stub = true
warn_no_return = true
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

[tool.pylint.MAIN]
extension-pkg-allow-list = [
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures for testing."""

import pytest


Expand Down

0 comments on commit 7cfecd0

Please sign in to comment.