summaryrefslogtreecommitdiff
path: root/searx/weather.py
AgeCommit message (Collapse)Author
2025-11-28Revert "[fix:py3.14] Struct fields aren't discovered in Python 3.14"Markus Heiser
This reverts commit 8fdc59a7604cd661638586ff0381530da86eb76c.
2025-11-01Revert "[fix] !weather crashes - cls.TURN .. (#5309)"Markus Heiser
This reverts HOTFIX from commit fc7d8b8b [1] [1] https://github.com/searxng/searxng/pull/5309 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-11-01[fix] msgspec.Struct: alias name t.ClassVar not properly detectedMarkus Heiser
Reported in [1], HOTFIX in [2], this patch here is now the final solution. Note that if using PEP 563 postponed evaluation of annotations" (e.g. ``from __future__ import annotations``) only the following spellings will work: ClassVar or ClassVar[<type>] typing.ClassVar or typing.ClassVar[<type>] Importing ClassVar or typing under an aliased name (e.g. ``import typing as t``) will not be properly detected. [3] [1] https://github.com/searxng/searxng/issues/5304#issuecomment-3394140820 [2] https://github.com/searxng/searxng/pull/5309 [3] https://jcristharif.com/msgspec/structs.html#class-variables Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-10-13[fix] !weather crashes - cls.TURN 'member_descriptor' isn't a float (#5309)Markus Heiser
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>
2025-10-08[fix:py3.14] using a non-empty mutable collection as default is unsafeMarkus Heiser
Starting with Python 3.14 msgspec reports:: File "/share/searxng/searx/weather.py", line 261, in <module> class Temperature(msgspec.Struct, kw_only=True): ...<60 lines>... return template.format(value=val_str, unit=unit) TypeError: Using a non-empty mutable collection (['°C', '°F', 'K']) \ as a default value is unsafe.\ Instead configure a `default_factory` for this field. The problem is solved by the fact that there are now global constants for the units (BTW singular/plural names of the type definitions are fixed): - TEMPERATURE_UNITS - PRESSURE_UNITS - WIND_SPEED_UNITS - RELATIVE_HUMIDITY_UNITS - COMPASS_POINTS - COMPASS_UNITS Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-10-08[fix:py3.14] Struct fields aren't discovered in Python 3.14Markus Heiser
This is a temporary workaround for #5284 [1]. However, the problem must be solved at a different level, in msgspec [2]. [1] https://github.com/searxng/searxng/issues/5284 [2] https://github.com/jcrist/msgspec/issues/847 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-10-01[fix] JSON format: serialization of the result-typesMarkus Heiser
The ``JSONEncoder`` (``format="json"``) must perform a conversion to the built-in types for the ``msgspec.Struct``:: if isinstance(o, msgspec.Struct): return msgspec.to_builtins(o) The result types are already of type ``msgspec.Struct``, so they can be converted into built-in types. The field types (in the result type) that were not yet of type ``msgspec.Struct`` have been converted to:: searx.weather.GeoLocation@dataclass -> msgspec.Struct searx.weather.DateTime -> msgspec.Struct searx.weather.Temperature -> msgspec.Struct searx.weather.PressureUnits -> msgspec.Struct searx.weather.WindSpeed -> msgspec.Struct searx.weather.RelativeHumidity -> msgspec.Struct searx.weather.Compass -> msgspec.Struct BTW: Wherever it seemed sensible, the typing was also modernized in the modified files. Closes: https://github.com/searxng/searxng/issues/5250 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-09-20[mod] typification of SearXNG: add new result type PaperMarkus Heiser
This patch adds a new result type: Paper - Python class: searx/result_types/paper.py - Jinja template: searx/templates/simple/result_templates/paper.html - CSS (less) client/simple/src/less/result_types/paper.less Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-09-03[mod] drop: from __future__ import annotationsMarkus Heiser
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-09-03[mod] addition of various type hints / tbcMarkus Heiser
- pyright configuration [1]_ - stub files: types-lxml [2]_ - addition of various type hints - enable use of new type system features on older Python versions [3]_ - ``.tool-versions`` - set python to lowest version we support (3.10.18) [4]_: Older versions typically lack some typing features found in newer Python versions. Therefore, for local type checking (before commit), it is necessary to use the older Python interpreter. .. [1] https://docs.basedpyright.com/v1.20.0/configuration/config-files/ .. [2] https://pypi.org/project/types-lxml/ .. [3] https://typing-extensions.readthedocs.io/en/latest/# .. [4] https://mise.jdx.dev/configuration.html#tool-versions Signed-off-by: Markus Heiser <markus.heiser@darmarit.de> Format: reST
2025-08-28[feat] plugins: add new time/timezone search pluginBnyro
The plugin uses the ``GeoLocation`` class, which is already implemented in the context of weather forecasts, to determine the time zone. The ``DateTime`` class is used for the localized display of date and time. Co-authored-by: Markus Heiser <markus.heiser@darmarit.de>
2025-07-03[feat] wttr.in: migrate to new weather engine template (#4888)Bnyro
Author Notes - wttr.in provides 8 hourly time forecasts per day, I assumed that they're always describing the weather for 3 hours each, starting at 1 o'clock in the morning related: - https://github.com/searxng/searxng/pull/4663 - https://github.com/searxng/searxng/issues/4885
2025-05-31[mod] weather results: add types, i18n/l10n, symbols & unit conversionsMarkus Heiser
The types necessary for weather information such as GeoLocation, DateTime, Temperature,Pressure, WindSpeed, RelativeHumidity, Compass (wind direction) and symbols for the weather have been implemented. There are unit conversions and translations for weather property labels. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>