Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
run: pipx install hatch
- name: Lint and typecheck
run: |
hatch run lint-check
hatch fmt --linter
- name: Test
run: |
hatch test --all

- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
fail_ci_if_error: false
verbose: true

release:
Expand Down
46 changes: 16 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
description = "Simple Python wrapper for Uptime Kuma"
readme = "README.md"
license = "MIT"
requires-python = ">=3.8.0"
requires-python = ">=3.12"
authors = [
{ name = "Manfred Dennerlein Rodelo", email = "manfred@dennerlein.name" },
{ name = "Jayakorn Karikan", email = "jayakornk@gmail.com" },
Expand Down Expand Up @@ -40,32 +40,18 @@ include = [
"/pythonkuma",
]

[tool.ruff]
target-version = "py312"
line-length = 88

[tool.ruff.lint]
preview = true
ignore = ["TRY003", "N818"]


[tool.ruff.lint.isort]
force-sort-within-sections = true
known-first-party = ["pythonkuma"]
combine-as-imports = true
split-on-trailing-comma = false

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.format]
preview = true
quote-style = "double"
indent-style = "space"

[tool.ruff.lint.mccabe]
max-complexity = 25

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.hatch.envs.hatch-static-analysis]
dependencies = ["ruff==0.11.13"]
config-path = "ruff.toml"

[tool.pytest.ini_options]
addopts = "--cov=pythonkuma/ --cov-report=term-missing"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope="module"
testpaths = ["tests"]
pythonpath = ["pythonkuma"]

[tool.hatch.envs.hatch-test]
extra-dependencies = [
"pytest-cov"
]
1 change: 1 addition & 0 deletions pythonkuma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Python API wrapper for Uptime Kuma."""

from .exceptions import (
UptimeKumaAuthenticationException,
UptimeKumaConnectionException,
Expand Down
1 change: 1 addition & 0 deletions pythonkuma/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Uptime Kuma constants."""

from logging import Logger, getLogger

LOGGER: Logger = getLogger(__package__)
5 changes: 2 additions & 3 deletions pythonkuma/decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Decorator for Uptime Kuma"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -44,9 +45,7 @@ async def wrapper(*args, **kwargs):
) from exception

except TimeoutError:
raise exceptions.UptimeKumaConnectionException(
f"Request timeout for '{url}'"
) from None
raise exceptions.UptimeKumaConnectionException(f"Request timeout for '{url}'") from None

except exceptions.UptimeKumaConnectionException as exception:
raise exceptions.UptimeKumaConnectionException(exception) from exception
Expand Down
11 changes: 3 additions & 8 deletions pythonkuma/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Uptime Kuma models"""

from __future__ import annotations

from dataclasses import dataclass
Expand Down Expand Up @@ -87,20 +88,14 @@ def from_prometheus(data: dict[str, Any]) -> UptimeKumaApiResponse:
for sample in family.samples:
if sample.name.startswith("monitor"):
existed = next(
(
i
for i, x in enumerate(monitors)
if x["monitor_name"] == sample.labels["monitor_name"]
),
(i for i, x in enumerate(monitors) if x["monitor_name"] == sample.labels["monitor_name"]),
None,
)
if existed is None:
temp = {**sample.labels, sample.name: sample.value}
monitors.append(temp)
else:
monitors[existed][sample.name] = sample.value
obj["data"] = [
UptimeKumaMonitor.from_dict(monitor) for monitor in monitors
]
obj["data"] = [UptimeKumaMonitor.from_dict(monitor) for monitor in monitors]

return UptimeKumaApiResponse(**obj)
1 change: 1 addition & 0 deletions pythonkuma/uptimekuma.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Uptime Kuma client."""

from aiohttp import ClientSession

from .decorator import api_request
Expand Down
38 changes: 38 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
line-length = 120

[format]
docstring-code-format = true
docstring-code-line-length = 80
quote-style = "double"
indent-style = "space"

[lint]

[lint.per-file-ignores]
"**/scripts/*" = [
"INP001",
"T201",
]
"**/tests/**/*" = [
"PLC1901",
"PLR2004",
"PLR6301",
"S",
"TID252",
]

[lint.flake8-tidy-imports]
ban-relative-imports = "parents"

[lint.isort]
known-first-party = ["pyuptimekuma"]
force-sort-within-sections = true
combine-as-imports = true
split-on-trailing-comma = false

[lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false

[lint.pydocstyle]
convention = "numpy"
Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_dummy():
pass
Loading