Skip to content

Commit

Permalink
Fixes source code, upgrade workflows - pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wilbiev committed Dec 25, 2024
1 parent 292532e commit 289b3c5
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automatic-custom-card-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
docit:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: "Copy and rename README.md files"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "⤵️ Check out code from GitHub"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "⚙️ Set up Python"
uses: "actions/setup-python@v4"
with:
python-version: 3.8
python-version: 3.11
- name: "⚙️ Set up Ruby"
uses: "ruby/setup-ruby@v1"
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

steps:
- name: "Checkout repository"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

# Initializes the CodeQL tools for scanning.
- name: "Initialize CodeQL"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/hacs-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "validation"
uses: "home-assistant/actions/hassfest@master"

Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "checkout"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "validation"
uses: "hacs/action@main"
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "⤵️ Check out code from GitHub"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "\U0001F680 Run Labeler"
uses: "crazy-max/ghaction-github-labeler@v4"
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
deploy:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
with:
node-version: "16.x"
node-version: "20.x"
- uses: "actions/setup-python@v4"
with:
python-version: "3.11"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Check out repository"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Get version"
id: "version"
Expand Down
1 change: 1 addition & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ MD001: false

MD024:
allow_different_nesting: true
siblings_only: true

MD025: false

Expand Down
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ci:

repos:
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v4.2.0"
rev: "v5.0.0"
hooks:
- id: "check-executables-have-shebangs"
- id: "check-json"
Expand All @@ -30,7 +30,7 @@ repos:
- id: "mixed-line-ending"

- repo: "https://github.com/adrienverge/yamllint.git"
rev: "v1.26.3"
rev: "v1.35.1"
hooks:
- id: "yamllint"
args: ["--format", "parsable", "--strict"]
Expand All @@ -41,13 +41,13 @@ repos:
)$
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
rev: v0.43.0
hooks:
- id: markdownlint
args: ["--fix"]

- repo: "https://github.com/jumanjihouse/pre-commit-hook-yamlfmt"
rev: "0.1.1"
rev: "0.2.3"
hooks:
- id: "yamlfmt"
args:
Expand All @@ -63,23 +63,23 @@ repos:
exclude: ".*"

- repo: "https://github.com/mattlqx/pre-commit-search-and-replace"
rev: "v1.0.5"
rev: "v1.1.8"
hooks:
- id: "search-and-replace"

- repo: "https://github.com/asottile/pyupgrade"
rev: "v2.31.1"
rev: "v3.19.1"
hooks:
- id: "pyupgrade"
args: ["--py39-plus"]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: "https://github.com/psf/black"
rev: "22.3.0"
rev: "24.10.0"
hooks:
- id: "black"
args:
Expand All @@ -89,7 +89,7 @@ repos:
files: '^((custom_components|tests)/.+)?[^/]+\.py$'

- repo: "https://github.com/PyCQA/flake8"
rev: "4.0.1"
rev: "7.1.1"
hooks:
- id: "flake8"
additional_dependencies:
Expand All @@ -99,7 +99,7 @@ repos:
files: '^(custom_components/.+)?[^/]+\.py$'

- repo: "https://github.com/PyCQA/bandit"
rev: "1.7.4"
rev: "1.8.0"
hooks:
- id: "bandit"
args:
Expand All @@ -108,7 +108,7 @@ repos:
# - "--configfile=bandit.yaml"
<<: *python-files-with-tests
- repo: https://github.com/codespell-project/codespell.git
rev: "v2.1.0"
rev: "v2.3.0"
hooks:
- id: codespell
files: "(.*.md|translations/en.json)"
Expand Down
3 changes: 3 additions & 0 deletions custom_cards/custom_card_imswel_medias/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Initial release
## Requirements

This card needs the following to function correctly:

| Component | Required |
| ----------------------------------------------------------------------------------------- | ---------------------------------- |
|[Plex Recently Added](https://github.com/NemesisRE/sensor.plex_recently_added) | Yes for **`Media Library Card`** |
Expand All @@ -40,6 +41,7 @@ This card needs the following to function correctly:
**Media Library Card** for [Plex Recently Added](https://github.com/NemesisRE/sensor.plex_recently_added) :

![example-image-plex](../../docs/assets/img/custom_card_imswel_medias/medias_library_plex.png)<br>

| Variable | Default | Required | Notes |
| ----------------------------- | ------- | -------- | ----------------------------------------------------------------------- |
| ulm_custom_card_imswel_medias_index | 1 | Yes | The index of the item in your **Plex library** to show. |
Expand All @@ -58,6 +60,7 @@ This card needs the following to function correctly:
![example-image-radarr](../../docs/assets/img/custom_card_imswel_medias/medias_upcoming_radarr.png)
![example-image-sonarr](../../docs/assets/img/custom_card_imswel_medias/medias_upcoming_sonarr.png)<br>
| Variable | Default | Required | Notes |
| ----------------------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------- |
| ulm_custom_card_imswel_medias_index | 1 | Yes | The index of the item in your **Radarr/Sonarr library** to show. |
Expand Down
3 changes: 3 additions & 0 deletions custom_components/ui_lovelace_minimalist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.loader import async_get_integration
import voluptuous as vol

from .base import UlmBase
from .const import DOMAIN, NAME
from .enums import ConfigurationType, UlmDisabledReason

_LOGGER: logging.Logger = logging.getLogger(__package__)

CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA)


async def async_initialize_integration(
hass: HomeAssistant,
Expand Down
9 changes: 5 additions & 4 deletions custom_components/ui_lovelace_minimalist/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

from __future__ import annotations

from collections.abc import Awaitable
from dataclasses import asdict, dataclass, field
from functools import partial
import logging
import os
import pathlib
import shutil
from typing import Any, Awaitable, Callable
from typing import Any, Callable

from aiogithubapi import (
GitHubAPI,
Expand Down Expand Up @@ -419,9 +420,9 @@ async def configure_dashboard(self) -> bool:
async_remove_panel(self.hass, "ui-lovelace-minimalist")

if self.configuration.adaptive_ui_enabled:
self.hass.data["lovelace"]["dashboards"][
adv_dashboard_url
] = LovelaceYAML(self.hass, adv_dashboard_url, adv_dashboard_config)
self.hass.data["lovelace"]["dashboards"][adv_dashboard_url] = (
LovelaceYAML(self.hass, adv_dashboard_url, adv_dashboard_config)
)

_register_panel(
self.hass, adv_dashboard_url, "yaml", adv_dashboard_config, True
Expand Down
11 changes: 10 additions & 1 deletion custom_components/ui_lovelace_minimalist/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

from aiogithubapi import GitHubDeviceAPI, GitHubException
from aiogithubapi.common.const import OAUTH_USER_LOGIN
from awesomeversion import AwesomeVersion
from homeassistant import config_entries
from homeassistant.const import __version__ as HAVERSION
from homeassistant.core import callback
from homeassistant.helpers import aiohttp_client
import homeassistant.helpers.config_validation as cv
Expand Down Expand Up @@ -51,6 +53,10 @@

_LOGGER: logging.Logger = logging.getLogger(__name__)

# Version threshold for config_entry setting in options flow
# See: https://github.com/home-assistant/core/pull/129562
HA_OPTIONS_FLOW_VERSION_THRESHOLD = "2024.11.99"


async def ulm_config_option_schema(options: dict = {}) -> dict:
"""Return a schema for ULM configuration options."""
Expand Down Expand Up @@ -242,7 +248,10 @@ class UlmOptionFlowHandler(config_entries.OptionsFlow):

def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize."""
self.config_entry = config_entry
self.options = dict(config_entry.options)
# See: https://github.com/home-assistant/core/pull/129562
if AwesomeVersion(HAVERSION) < HA_OPTIONS_FLOW_VERSION_THRESHOLD:
self.config_entry = config_entry

async def async_step_init(self, _user_input=None):
"""Manage the options."""
Expand Down
34 changes: 17 additions & 17 deletions custom_components/ui_lovelace_minimalist/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants for UI Lovelace Minimalist."""

from typing import TypeVar

# Base component constants
Expand All @@ -19,50 +20,49 @@
COMMUNITY_CARDS_FOLDER = "custom_cards"

LANGUAGES = {
"Català": "ca",
"Czech": "cs",
"Danish": "da",
"Dutch": "nl",
"German": "de",
"English (GB)": "en",
"Spanish": "es",
"Català": "ca",
"French": "fr",
"German": "de",
"Hebrew": "he",
"Italian": "it",
"Dutch": "nl",
"Hebrew": "he",
"Norwegian": "no",
"Polish": "pl",
"Portuguese (Brazil)": "pt-BR",
"Portuguese": "pt",
"Russian": "ru",
"Slovak": "sk",
"Portuguese (Brazil)": "pt-BR",
"Slovenian": "sl",
"Spanish": "es",
"Slovak": "sk",
"Swedish": "sv",
"Turkish": "tr",
"Ukrainian": "uk",
"Russian": "ru",
"中文(简体)": "zh-CN",
}

CONF_LANGUAGE = "language"
CONF_LANGUAGES = [
"Català",
"Czech",
"Danish",
"Dutch",
"German",
"English (GB)",
"Spanish",
"Català",
"French",
"German",
"Hebrew",
"Italian",
"Dutch",
"Hebrew",
"Norwegian",
"Polish",
"Portuguese (Brazil)",
"Portuguese",
"Russian",
"Portuguese (Brazil)",
"Slovenian",
"Spanish",
"Slovak",
"Swedish",
"Turkish",
"Ukrainian",
"Russian",
"中文(简体)",
]
CONF_SIDEPANEL_ENABLED = "sidepanel_enabled"
Expand Down
1 change: 1 addition & 0 deletions custom_components/ui_lovelace_minimalist/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper constants."""

# pylint: disable=missing-class-docstring
from enum import Enum

Expand Down
1 change: 1 addition & 0 deletions custom_components/ui_lovelace_minimalist/utils/decode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Util to decode content from the github API."""

from base64 import b64decode


Expand Down
1 change: 1 addition & 0 deletions custom_components/ui_lovelace_minimalist/utils/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom logger for HACS."""

import logging

from ..const import PACKAGE_NAME
Expand Down
3 changes: 3 additions & 0 deletions docs/usage/custom_cards/custom_card_imswel_medias.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Initial release
## Requirements

This card needs the following to function correctly:

| Component | Required |
| ----------------------------------------------------------------------------------------- | ---------------------------------- |
|[Plex Recently Added](https://github.com/NemesisRE/sensor.plex_recently_added) | Yes for **`Media Library Card`** |
Expand All @@ -40,6 +41,7 @@ This card needs the following to function correctly:
**Media Library Card** for [Plex Recently Added](https://github.com/NemesisRE/sensor.plex_recently_added) :

![example-image-plex](../../assets/img/custom_card_imswel_medias/medias_library_plex.png)<br>

| Variable | Default | Required | Notes |
| ----------------------------- | ------- | -------- | ----------------------------------------------------------------------- |
| ulm_custom_card_imswel_medias_index | 1 | Yes | The index of the item in your **Plex library** to show. |
Expand All @@ -58,6 +60,7 @@ This card needs the following to function correctly:
![example-image-radarr](../../assets/img/custom_card_imswel_medias/medias_upcoming_radarr.png)
![example-image-sonarr](../../assets/img/custom_card_imswel_medias/medias_upcoming_sonarr.png)<br>
| Variable | Default | Required | Notes |
| ----------------------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------- |
| ulm_custom_card_imswel_medias_index | 1 | Yes | The index of the item in your **Radarr/Sonarr library** to show. |
Expand Down

0 comments on commit 289b3c5

Please sign in to comment.