mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-12 21:08:13 +00:00
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:
@@ -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()
|
||||
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user