From 32e3eb5c6e52405559ac78a35c2b9c293d1f1719 Mon Sep 17 00:00:00 2001 From: Christin Date: Tue, 7 Jul 2026 06:27:01 +0000 Subject: [PATCH] fix(prediction): drop module-level `from urllib.parse import quote` tests/test_docstringrst.py scans every class/function member of each module via inspect.getmembers() with no __module__ filter, so `from urllib.parse import quote` pulled the stdlib quote() into the pvnode and Solcast provider namespaces and its non-reST docstring failed the docstring-compliance check. Import `urllib.parse` as a module and call `urllib.parse.quote(...)` instead: a module member is skipped by the isfunction/isclass scan, and the fully-qualified call keeps mypy happy (the requests stubs lack quote, which is why urllib.parse was chosen over requests.utils in the first place). test_all_docstrings_rst_compliant now passes; isort/ruff/ruff-format/mypy pre-commit hooks all green. --- src/akkudoktoreos/prediction/pvforecastpvnode.py | 4 ++-- src/akkudoktoreos/prediction/pvforecastsolcast.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/akkudoktoreos/prediction/pvforecastpvnode.py b/src/akkudoktoreos/prediction/pvforecastpvnode.py index 4b08eac..afe6985 100644 --- a/src/akkudoktoreos/prediction/pvforecastpvnode.py +++ b/src/akkudoktoreos/prediction/pvforecastpvnode.py @@ -21,8 +21,8 @@ Notes: """ import re +import urllib.parse from typing import Any, Optional -from urllib.parse import quote import pendulum import requests @@ -166,7 +166,7 @@ class PVForecastPVNode(PVForecastProvider): try: if site_id: - url = f"{PVNODE_BASE}/forecast/{quote(site_id, safe='')}" + url = f"{PVNODE_BASE}/forecast/{urllib.parse.quote(site_id, safe='')}" response = requests.get(url, headers=headers, params=params, timeout=30) else: body = self._inline_body() diff --git a/src/akkudoktoreos/prediction/pvforecastsolcast.py b/src/akkudoktoreos/prediction/pvforecastsolcast.py index 004050c..60a022a 100644 --- a/src/akkudoktoreos/prediction/pvforecastsolcast.py +++ b/src/akkudoktoreos/prediction/pvforecastsolcast.py @@ -17,8 +17,8 @@ Notes: """ import re +import urllib.parse from typing import Any, Optional -from urllib.parse import quote import requests from loguru import logger @@ -85,7 +85,7 @@ class PVForecastSolcast(PVForecastProvider): if not settings.api_key or not settings.site_id: raise ValueError("PVForecastSolcast requires api_key and site_id") - url = f"{SOLCAST_BASE}/{quote(settings.site_id, safe='')}/forecasts" + url = f"{SOLCAST_BASE}/{urllib.parse.quote(settings.site_id, safe='')}/forecasts" params = {"format": "json", "hours": "72"} headers = {"Authorization": f"Bearer {settings.api_key}", "Accept": "application/json"} logger.debug(f"Requesting Solcast forecast: {url}")