From 98e693c1be0070dd67636e2e415c6fd9e301ab6e Mon Sep 17 00:00:00 2001 From: ludeeus Date: Mon, 22 Jul 2024 13:49:51 +0000 Subject: [PATCH] Add ruff config --- .ruff.toml | 43 +++++++++++++++++++ custom_components/healthchecksio/__init__.py | 3 +- .../healthchecksio/binary_sensor.py | 2 +- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .ruff.toml diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..008b8ee --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,43 @@ +# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml + +target-version = "py312" + +[lint] +select = [ + "ALL", +] + +ignore = [ + "ANN001", # Missing type annotation for function argument + "ANN101", # Missing type annotation for `self` in method + "ANN201", # Missing return type annotation for public function + "ANN202", # Missing return type annotation for private function + "ANN204", # Missing return type annotation for special method + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed + "ARG001", # Unused function argument: `hass` + "BLE001", # Do not catch blind exception: `Exception + "COM812", # incompatible with formatter + "D102", # Missing docstring in public method + "D107", # Missing docstring in `__init__` + "D203", # no-blank-line-before-class (incompatible with formatter) + "D212", # multi-line-summary-first-line (incompatible with formatter) + "D400", # First line should end with a period + "D401", # First line of docstring should be in imperative mood + "D404", # First word of the docstring should not be "This" + "D415", # First line should end with a period, question mark, or exclamation point + "FBT003", # Boolean positional value in function call + "ISC001", # incompatible with formatter + "PLR0913", # Too many arguments in function definition + "PTH110", # `os.path.exists()` should be replaced by `Path.exists()` + "RET505", # Unnecessary `else` after `return` statement + "TRY300", # Consider moving this statement to an `else` block +] + +[lint.flake8-pytest-style] +fixture-parentheses = false + +[lint.pyupgrade] +keep-runtime-typing = true + +[lint.mccabe] +max-complexity = 25 diff --git a/custom_components/healthchecksio/__init__.py b/custom_components/healthchecksio/__init__.py index 91a1293..678eddb 100644 --- a/custom_components/healthchecksio/__init__.py +++ b/custom_components/healthchecksio/__init__.py @@ -85,7 +85,6 @@ async def async_unload_entry( hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry ) -> bool: """Unload a config entry.""" - unload_ok = await hass.config_entries.async_forward_entry_unload( config_entry, Platform.BINARY_SENSOR ) @@ -142,7 +141,7 @@ async def check_files(hass: core.HomeAssistant) -> bool: base = f"{hass.config.path()}/custom_components/{DOMAIN}/" missing = [] for file in REQUIRED_FILES: - fullpath = "{}{}".format(base, file) + fullpath = f"{base}{file}" if not os.path.exists(fullpath): missing.append(file) diff --git a/custom_components/healthchecksio/binary_sensor.py b/custom_components/healthchecksio/binary_sensor.py index a2e602c..12647df 100644 --- a/custom_components/healthchecksio/binary_sensor.py +++ b/custom_components/healthchecksio/binary_sensor.py @@ -7,7 +7,7 @@ BinarySensorDevice as BinarySensorEntity, ) -from .const import ATTRIBUTION, BINARY_SENSOR_DEVICE_CLASS, DOMAIN_DATA, DOMAIN +from .const import ATTRIBUTION, BINARY_SENSOR_DEVICE_CLASS, DOMAIN, DOMAIN_DATA async def async_setup_entry(hass, config_entry, async_add_devices):