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.
This commit is contained in:
Christin
2026-07-07 06:27:01 +00:00
parent 2c89e3fee9
commit 32e3eb5c6e
2 changed files with 4 additions and 4 deletions

View File

@@ -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()

View File

@@ -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}")