summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2025-10-13 07:37:42 +0200
committerGitHub <noreply@github.com>2025-10-13 07:37:42 +0200
commitfc7d8b8be221874f8dac0dcedf6ca02a45beca22 (patch)
tree25cc398507ca6caf4592601718657bffefe0ba78
parent5492de15bb7ae3e10fb6ba9393702e9b0a05c615 (diff)
[fix] !weather crashes - cls.TURN 'member_descriptor' isn't a float (#5309)
The class method ``Compass.point`` is converted into an instance method to circumvent the problem described in [1] (without understanding the cause). [1] https://github.com/searxng/searxng/issues/5304#issuecomment-3394140820 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
-rw-r--r--searx/weather.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/searx/weather.py b/searx/weather.py
index 429758055..3bd7f93cb 100644
--- a/searx/weather.py
+++ b/searx/weather.py
@@ -506,15 +506,14 @@ class Compass(msgspec.Struct):
return self.val
raise ValueError(f"unknown unit: {unit}")
- @classmethod
- def point(cls, azimuth: float | int) -> CompassPoint:
+ def point(self, azimuth: float | int) -> CompassPoint:
"""Returns the compass point to an azimuth value."""
- azimuth = azimuth % cls.TURN
+ azimuth = azimuth % self.TURN
# The angle sector of a compass point starts 1/2 sector range before
# and after compass point (example: "N" goes from -11.25° to +11.25°)
- azimuth = azimuth - cls.RANGE / 2
- idx = int(azimuth // cls.RANGE)
- return cls.POINTS[idx]
+ azimuth = azimuth - self.RANGE / 2
+ idx = int(azimuth // self.RANGE)
+ return self.POINTS[idx]
def l10n(
self,