mirror of
https://github.com/searxng/searxng.git
synced 2026-07-29 03:11:25 +00:00
Compare commits
3 Commits
d8d5de4d47
...
898fbe7bc2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
898fbe7bc2 | ||
|
|
d16283d93a | ||
|
|
8fdc59a760 |
4
.github/workflows/integration.yml
vendored
4
.github/workflows/integration.yml
vendored
@@ -25,14 +25,13 @@ jobs:
|
|||||||
name: Python ${{ matrix.python-version }}
|
name: Python ${{ matrix.python-version }}
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
matrix:
|
||||||
python-version:
|
python-version:
|
||||||
- "3.10"
|
- "3.10"
|
||||||
- "3.11"
|
- "3.11"
|
||||||
- "3.12"
|
- "3.12"
|
||||||
- "3.13"
|
- "3.13"
|
||||||
- "3.14-dev"
|
- "3.14"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
@@ -56,7 +55,6 @@ jobs:
|
|||||||
run: make V=1 install
|
run: make V=1 install
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
continue-on-error: ${{ matrix.python-version == '3.14-dev' }}
|
|
||||||
run: make V=1 ci.test
|
run: make V=1 ci.test
|
||||||
|
|
||||||
theme:
|
theme:
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
----
|
----
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ["ExpireCacheCfg", "ExpireCacheStats", "ExpireCache", "ExpireCacheSQLite"]
|
__all__ = ["ExpireCacheCfg", "ExpireCacheStats", "ExpireCache", "ExpireCacheSQLite"]
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# pylint: disable=missing-module-docstring
|
# pylint: disable=missing-module-docstring
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
import msgspec
|
import msgspec
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""Implementations for a favicon proxy"""
|
"""Implementations for a favicon proxy"""
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
:members:
|
:members:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ["Result"]
|
__all__ = ["Result"]
|
||||||
|
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ template.
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ["AnswerSet", "Answer", "Translations", "WeatherAnswer"]
|
__all__ = ["AnswerSet", "Answer", "Translations", "WeatherAnswer"]
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ template. For highlighting the code passages, Pygments_ is used.
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods, disable=invalid-name
|
# pylint: disable=too-few-public-methods, disable=invalid-name
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ["Code"]
|
__all__ = ["Code"]
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ template.
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ["KeyValue"]
|
__all__ = ["KeyValue"]
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ Related topics:
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods, disable=invalid-name
|
# pylint: disable=too-few-public-methods, disable=invalid-name
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ["Paper"]
|
__all__ = ["Paper"]
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
"""Implementations used for weather conditions and forecast."""
|
"""Implementations used for weather conditions and forecast."""
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
|
# Struct fields aren't discovered in Python 3.14
|
||||||
|
# - https://github.com/searxng/searxng/issues/5284
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"symbol_url",
|
"symbol_url",
|
||||||
"Temperature",
|
"Temperature",
|
||||||
@@ -251,7 +255,8 @@ class DateTime(msgspec.Struct):
|
|||||||
return babel.dates.format_date(self.datetime, format=fmt, locale=locale)
|
return babel.dates.format_date(self.datetime, format=fmt, locale=locale)
|
||||||
|
|
||||||
|
|
||||||
TemperatureUnits: t.TypeAlias = t.Literal["°C", "°F", "K"]
|
TemperatureUnit: t.TypeAlias = t.Literal["°C", "°F", "K"]
|
||||||
|
TEMPERATURE_UNITS: t.Final[tuple[TemperatureUnit]] = t.get_args(TemperatureUnit)
|
||||||
|
|
||||||
|
|
||||||
class Temperature(msgspec.Struct, kw_only=True):
|
class Temperature(msgspec.Struct, kw_only=True):
|
||||||
@@ -259,19 +264,19 @@ class Temperature(msgspec.Struct, kw_only=True):
|
|||||||
measured values."""
|
measured values."""
|
||||||
|
|
||||||
val: float
|
val: float
|
||||||
unit: TemperatureUnits
|
unit: TemperatureUnit
|
||||||
|
|
||||||
si_name: t.ClassVar[str] = "Q11579"
|
si_name: t.ClassVar[str] = "Q11579"
|
||||||
units: t.ClassVar[list[str]] = list(t.get_args(TemperatureUnits))
|
UNITS: t.ClassVar[tuple[TemperatureUnit]] = TEMPERATURE_UNITS
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if self.unit not in self.units:
|
if self.unit not in self.UNITS:
|
||||||
raise ValueError(f"invalid unit: {self.unit}")
|
raise ValueError(f"invalid unit: {self.unit}")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.l10n()
|
return self.l10n()
|
||||||
|
|
||||||
def value(self, unit: TemperatureUnits) -> float:
|
def value(self, unit: TemperatureUnit) -> float:
|
||||||
if unit == self.unit:
|
if unit == self.unit:
|
||||||
return self.val
|
return self.val
|
||||||
si_val = convert_to_si(si_name=self.si_name, symbol=self.unit, value=self.val)
|
si_val = convert_to_si(si_name=self.si_name, symbol=self.unit, value=self.val)
|
||||||
@@ -279,7 +284,7 @@ class Temperature(msgspec.Struct, kw_only=True):
|
|||||||
|
|
||||||
def l10n(
|
def l10n(
|
||||||
self,
|
self,
|
||||||
unit: TemperatureUnits | None = None,
|
unit: TemperatureUnit | None = None,
|
||||||
locale: babel.Locale | GeoLocation | None = None,
|
locale: babel.Locale | GeoLocation | None = None,
|
||||||
template: str = "{value} {unit}",
|
template: str = "{value} {unit}",
|
||||||
num_pattern: str = "#,##0",
|
num_pattern: str = "#,##0",
|
||||||
@@ -318,7 +323,8 @@ class Temperature(msgspec.Struct, kw_only=True):
|
|||||||
return template.format(value=val_str, unit=unit)
|
return template.format(value=val_str, unit=unit)
|
||||||
|
|
||||||
|
|
||||||
PressureUnits: t.TypeAlias = t.Literal["Pa", "hPa", "cm Hg", "bar"]
|
PressureUnit: t.TypeAlias = t.Literal["Pa", "hPa", "cm Hg", "bar"]
|
||||||
|
PRESSURE_UNITS: t.Final[tuple[PressureUnit]] = t.get_args(PressureUnit)
|
||||||
|
|
||||||
|
|
||||||
class Pressure(msgspec.Struct, kw_only=True):
|
class Pressure(msgspec.Struct, kw_only=True):
|
||||||
@@ -326,19 +332,19 @@ class Pressure(msgspec.Struct, kw_only=True):
|
|||||||
measured values."""
|
measured values."""
|
||||||
|
|
||||||
val: float
|
val: float
|
||||||
unit: PressureUnits
|
unit: PressureUnit
|
||||||
|
|
||||||
si_name: t.ClassVar[str] = "Q44395"
|
si_name: t.ClassVar[str] = "Q44395"
|
||||||
units: t.ClassVar[list[str]] = list(t.get_args(PressureUnits))
|
UNITS: t.ClassVar[tuple[PressureUnit]] = PRESSURE_UNITS
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if self.unit not in self.units:
|
if self.unit not in self.UNITS:
|
||||||
raise ValueError(f"invalid unit: {self.unit}")
|
raise ValueError(f"invalid unit: {self.unit}")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.l10n()
|
return self.l10n()
|
||||||
|
|
||||||
def value(self, unit: PressureUnits) -> float:
|
def value(self, unit: PressureUnit) -> float:
|
||||||
if unit == self.unit:
|
if unit == self.unit:
|
||||||
return self.val
|
return self.val
|
||||||
si_val = convert_to_si(si_name=self.si_name, symbol=self.unit, value=self.val)
|
si_val = convert_to_si(si_name=self.si_name, symbol=self.unit, value=self.val)
|
||||||
@@ -346,7 +352,7 @@ class Pressure(msgspec.Struct, kw_only=True):
|
|||||||
|
|
||||||
def l10n(
|
def l10n(
|
||||||
self,
|
self,
|
||||||
unit: PressureUnits | None = None,
|
unit: PressureUnit | None = None,
|
||||||
locale: babel.Locale | GeoLocation | None = None,
|
locale: babel.Locale | GeoLocation | None = None,
|
||||||
template: str = "{value} {unit}",
|
template: str = "{value} {unit}",
|
||||||
num_pattern: str = "#,##0",
|
num_pattern: str = "#,##0",
|
||||||
@@ -363,7 +369,8 @@ class Pressure(msgspec.Struct, kw_only=True):
|
|||||||
return template.format(value=val_str, unit=unit)
|
return template.format(value=val_str, unit=unit)
|
||||||
|
|
||||||
|
|
||||||
WindSpeedUnits: t.TypeAlias = t.Literal["m/s", "km/h", "kn", "mph", "mi/h", "Bft"]
|
WindSpeedUnit: t.TypeAlias = t.Literal["m/s", "km/h", "kn", "mph", "mi/h", "Bft"]
|
||||||
|
WIND_SPEED_UNITS: t.Final[tuple[WindSpeedUnit]] = t.get_args(WindSpeedUnit)
|
||||||
|
|
||||||
|
|
||||||
class WindSpeed(msgspec.Struct, kw_only=True):
|
class WindSpeed(msgspec.Struct, kw_only=True):
|
||||||
@@ -378,19 +385,19 @@ class WindSpeed(msgspec.Struct, kw_only=True):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
val: float
|
val: float
|
||||||
unit: WindSpeedUnits
|
unit: WindSpeedUnit
|
||||||
|
|
||||||
si_name: t.ClassVar[str] = "Q182429"
|
si_name: t.ClassVar[str] = "Q182429"
|
||||||
units: t.ClassVar[list[str]] = list(t.get_args(WindSpeedUnits))
|
UNITS: t.ClassVar[tuple[WindSpeedUnit]] = WIND_SPEED_UNITS
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if self.unit not in self.units:
|
if self.unit not in self.UNITS:
|
||||||
raise ValueError(f"invalid unit: {self.unit}")
|
raise ValueError(f"invalid unit: {self.unit}")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.l10n()
|
return self.l10n()
|
||||||
|
|
||||||
def value(self, unit: WindSpeedUnits) -> float:
|
def value(self, unit: WindSpeedUnit) -> float:
|
||||||
if unit == self.unit:
|
if unit == self.unit:
|
||||||
return self.val
|
return self.val
|
||||||
si_val = convert_to_si(si_name=self.si_name, symbol=self.unit, value=self.val)
|
si_val = convert_to_si(si_name=self.si_name, symbol=self.unit, value=self.val)
|
||||||
@@ -398,7 +405,7 @@ class WindSpeed(msgspec.Struct, kw_only=True):
|
|||||||
|
|
||||||
def l10n(
|
def l10n(
|
||||||
self,
|
self,
|
||||||
unit: WindSpeedUnits | None = None,
|
unit: WindSpeedUnit | None = None,
|
||||||
locale: babel.Locale | GeoLocation | None = None,
|
locale: babel.Locale | GeoLocation | None = None,
|
||||||
template: str = "{value} {unit}",
|
template: str = "{value} {unit}",
|
||||||
num_pattern: str = "#,##0",
|
num_pattern: str = "#,##0",
|
||||||
@@ -415,7 +422,8 @@ class WindSpeed(msgspec.Struct, kw_only=True):
|
|||||||
return template.format(value=val_str, unit=unit)
|
return template.format(value=val_str, unit=unit)
|
||||||
|
|
||||||
|
|
||||||
RelativeHumidityUnits: t.TypeAlias = t.Literal["%"]
|
RelativeHumidityUnit: t.TypeAlias = t.Literal["%"]
|
||||||
|
RELATIVE_HUMIDITY_UNITS: t.Final[tuple[RelativeHumidityUnit]] = t.get_args(RelativeHumidityUnit)
|
||||||
|
|
||||||
|
|
||||||
class RelativeHumidity(msgspec.Struct):
|
class RelativeHumidity(msgspec.Struct):
|
||||||
@@ -424,8 +432,12 @@ class RelativeHumidity(msgspec.Struct):
|
|||||||
val: float
|
val: float
|
||||||
|
|
||||||
# there exists only one unit (%) --> set "%" as the final value (constant)
|
# there exists only one unit (%) --> set "%" as the final value (constant)
|
||||||
unit: t.ClassVar["t.Final[RelativeHumidityUnits]"] = "%"
|
unit: t.ClassVar[RelativeHumidityUnit] = "%"
|
||||||
units: t.ClassVar[list[str]] = list(t.get_args(RelativeHumidityUnits))
|
UNITS: t.ClassVar[tuple[RelativeHumidityUnit]] = RELATIVE_HUMIDITY_UNITS
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
if self.unit not in self.UNITS:
|
||||||
|
raise ValueError(f"invalid unit: {self.unit}")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.l10n()
|
return self.l10n()
|
||||||
@@ -453,20 +465,23 @@ CompassPoint: t.TypeAlias = t.Literal[
|
|||||||
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
|
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
|
||||||
]
|
]
|
||||||
"""Compass point type definition"""
|
"""Compass point type definition"""
|
||||||
|
COMPASS_POINTS: t.Final[tuple[CompassPoint]] = t.get_args(CompassPoint)
|
||||||
|
|
||||||
CompassUnits: t.TypeAlias = t.Literal["°", "Point"]
|
CompassUnit: t.TypeAlias = t.Literal["°", "Point"]
|
||||||
|
COMPASS_UNITS: t.Final[tuple[CompassUnit]] = t.get_args(CompassUnit)
|
||||||
|
|
||||||
|
|
||||||
class Compass(msgspec.Struct):
|
class Compass(msgspec.Struct):
|
||||||
"""Class for converting compass points and azimuth values (360°)"""
|
"""Class for converting compass points and azimuth values (360°)"""
|
||||||
|
|
||||||
val: "float | int | CompassPoint"
|
val: "float | int | CompassPoint"
|
||||||
unit: CompassUnits = "°"
|
unit: CompassUnit = "°"
|
||||||
|
UNITS: t.ClassVar[tuple[CompassUnit]] = COMPASS_UNITS
|
||||||
|
|
||||||
TURN: t.ClassVar[float] = 360.0
|
TURN: t.ClassVar[float] = 360.0
|
||||||
"""Full turn (360°)"""
|
"""Full turn (360°)"""
|
||||||
|
|
||||||
POINTS: t.ClassVar[list[CompassPoint]] = list(t.get_args(CompassPoint))
|
POINTS: t.ClassVar[tuple[CompassPoint]] = COMPASS_POINTS
|
||||||
"""Compass points."""
|
"""Compass points."""
|
||||||
|
|
||||||
RANGE: t.ClassVar[float] = TURN / len(POINTS)
|
RANGE: t.ClassVar[float] = TURN / len(POINTS)
|
||||||
@@ -484,7 +499,7 @@ class Compass(msgspec.Struct):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.l10n()
|
return self.l10n()
|
||||||
|
|
||||||
def value(self, unit: CompassUnits):
|
def value(self, unit: CompassUnit):
|
||||||
if unit == "Point" and isinstance(self.val, float):
|
if unit == "Point" and isinstance(self.val, float):
|
||||||
return self.point(self.val)
|
return self.point(self.val)
|
||||||
if unit == "°":
|
if unit == "°":
|
||||||
@@ -503,7 +518,7 @@ class Compass(msgspec.Struct):
|
|||||||
|
|
||||||
def l10n(
|
def l10n(
|
||||||
self,
|
self,
|
||||||
unit: CompassUnits = "Point",
|
unit: CompassUnit = "Point",
|
||||||
locale: babel.Locale | GeoLocation | None = None,
|
locale: babel.Locale | GeoLocation | None = None,
|
||||||
template: str = "{value}{unit}",
|
template: str = "{value}{unit}",
|
||||||
num_pattern: str = "#,##0",
|
num_pattern: str = "#,##0",
|
||||||
|
|||||||
Reference in New Issue
Block a user