Compare commits

...

4 Commits

Author SHA1 Message Date
Markus Heiser
0245327fc5 Revert "[fix] !weather crashes - cls.TURN .. (#5309)"
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 09:46:47 +01:00
Markus Heiser
b155e66fe5 [fix] msgspec.Struct: alias name t.ClassVar not properly detected
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-11-01 09:46:47 +01:00
dependabot[bot]
5712827703
[upd] web-client (simple): Bump the minor group (#5402)
Bumps the minor group in /client/simple with 2 updates: [@biomejs/biome](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome) and [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node).

Updates `@biomejs/biome` from 2.2.7 to 2.3.2
- [Release notes](https://github.com/biomejs/biome/releases)
- [Changelog](https://github.com/biomejs/biome/blob/main/packages/@biomejs/biome/CHANGELOG.md)
- [Commits](https://github.com/biomejs/biome/commits/@biomejs/biome@2.3.2/packages/@biomejs/biome)

Updates `@types/node` from 24.9.1 to 24.9.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@biomejs/biome"
  dependency-version: 2.3.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor
- dependency-name: "@types/node"
  dependency-version: 24.9.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor
2025-11-01 09:45:54 +01:00
dependabot[bot]
7ba53d302d
[upd] pypi: Bump the minor group with 3 updates (#5401)
Bumps the minor group with 3 updates: [granian](https://github.com/emmett-framework/granian), [selenium](https://github.com/SeleniumHQ/Selenium) and [granian[reload]](https://github.com/emmett-framework/granian).


Updates `granian` from 2.5.5 to 2.5.6
- [Release notes](https://github.com/emmett-framework/granian/releases)
- [Commits](https://github.com/emmett-framework/granian/compare/v2.5.5...v2.5.6)

Updates `selenium` from 4.37.0 to 4.38.0
- [Release notes](https://github.com/SeleniumHQ/Selenium/releases)
- [Commits](https://github.com/SeleniumHQ/Selenium/compare/selenium-4.37.0...selenium-4.38.0)

Updates `granian[reload]` from 2.5.5 to 2.5.6
- [Release notes](https://github.com/emmett-framework/granian/releases)
- [Commits](https://github.com/emmett-framework/granian/compare/v2.5.5...v2.5.6)

---
updated-dependencies:
- dependency-name: granian
  dependency-version: 2.5.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: minor
- dependency-name: selenium
  dependency-version: 4.38.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: minor
- dependency-name: granian[reload]
  dependency-version: 2.5.6
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: minor
2025-11-01 09:44:12 +01:00
6 changed files with 105 additions and 79 deletions

View File

@ -1,8 +1,8 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.7/schema.json",
"$schema": "https://biomejs.dev/schemas/2.3.2/schema.json",
"files": {
"ignoreUnknown": true,
"includes": ["**", "!dist", "!node_modules"]
"includes": ["**", "!!node_modules"]
},
"assist": {
"enabled": true,
@ -48,6 +48,7 @@
"nursery": {
"noDeprecatedImports": "warn",
"noImportCycles": "warn",
"noIncrementDecrement": "warn",
"noMisusedPromises": "warn",
"noUselessCatchBinding": "warn",
"noUselessUndefined": "warn",
@ -65,6 +66,7 @@
"style": {
"noCommonJs": "error",
"noEnum": "error",
"noImplicitBoolean": "error",
"noInferrableTypes": "error",
"noNamespace": "error",
"noNegationElse": "error",
@ -97,6 +99,7 @@
}
},
"useConsistentBuiltinInstantiation": "error",
"useConsistentCurlyBraces": "error",
"useConsistentMemberAccessibility": {
"level": "error",
"options": {
@ -109,6 +112,12 @@
"syntax": "explicit"
}
},
"useConsistentTypeDefinitions": {
"level": "error",
"options": {
"style": "type"
}
},
"useDefaultSwitchClause": "error",
"useExplicitLengthCheck": "error",
"useForOf": "error",
@ -117,6 +126,7 @@
"useNumericSeparators": "error",
"useObjectSpread": "error",
"useReadonlyClassProperties": "error",
"useSelfClosingElements": "error",
"useShorthandAssign": "error",
"useSingleVarDeclarator": "error",
"useThrowNewError": "error",
@ -146,5 +156,15 @@
"semicolons": "always",
"trailingCommas": "none"
}
},
"html": {
"experimentalFullSupportEnabled": true,
"formatter": {
"attributePosition": "auto",
"bracketSameLine": false,
"whitespaceSensitivity": "ignore",
"indentScriptAndStyle": true,
"selfCloseVoidElements": "always"
}
}
}

View File

@ -15,8 +15,8 @@
"swiped-events": "1.2.0"
},
"devDependencies": {
"@biomejs/biome": "2.2.7",
"@types/node": "~24.9.1",
"@biomejs/biome": "2.3.2",
"@types/node": "~24.9.2",
"browserslist": "~4.27.0",
"browserslist-to-esbuild": "~2.1.1",
"edge.js": "~6.3.0",
@ -49,9 +49,9 @@
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.27.1",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
"integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
"version": "7.28.5",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz",
"integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==",
"dev": true,
"license": "MIT",
"engines": {
@ -59,9 +59,9 @@
}
},
"node_modules/@biomejs/biome": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.2.7.tgz",
"integrity": "sha512-1a8j0UP1vXVUf3UzMZEJ/zS2VgAG6wU6Cuh/I764sUGI+MCnJs/9WaojHYBDCxCMLTgU60/WqnYof85emXmSBA==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.3.2.tgz",
"integrity": "sha512-8e9tzamuDycx7fdrcJ/F/GDZ8SYukc5ud6tDicjjFqURKYFSWMl0H0iXNXZEGmcmNUmABgGuHThPykcM41INgg==",
"dev": true,
"license": "MIT OR Apache-2.0",
"bin": {
@ -75,20 +75,20 @@
"url": "https://opencollective.com/biome"
},
"optionalDependencies": {
"@biomejs/cli-darwin-arm64": "2.2.7",
"@biomejs/cli-darwin-x64": "2.2.7",
"@biomejs/cli-linux-arm64": "2.2.7",
"@biomejs/cli-linux-arm64-musl": "2.2.7",
"@biomejs/cli-linux-x64": "2.2.7",
"@biomejs/cli-linux-x64-musl": "2.2.7",
"@biomejs/cli-win32-arm64": "2.2.7",
"@biomejs/cli-win32-x64": "2.2.7"
"@biomejs/cli-darwin-arm64": "2.3.2",
"@biomejs/cli-darwin-x64": "2.3.2",
"@biomejs/cli-linux-arm64": "2.3.2",
"@biomejs/cli-linux-arm64-musl": "2.3.2",
"@biomejs/cli-linux-x64": "2.3.2",
"@biomejs/cli-linux-x64-musl": "2.3.2",
"@biomejs/cli-win32-arm64": "2.3.2",
"@biomejs/cli-win32-x64": "2.3.2"
}
},
"node_modules/@biomejs/cli-darwin-arm64": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.2.7.tgz",
"integrity": "sha512-xBUUsebnO2/Qj1v7eZmKUy2ZcFkZ4/jLUkxN02Qup1RPoRaiW9AKXHrqS3L7iX6PzofHY2xuZ+Pb9kAcpoe0qA==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.3.2.tgz",
"integrity": "sha512-4LECm4kc3If0JISai4c3KWQzukoUdpxy4fRzlrPcrdMSRFksR9ZoXK7JBcPuLBmd2SoT4/d7CQS33VnZpgBjew==",
"cpu": [
"arm64"
],
@ -103,9 +103,9 @@
}
},
"node_modules/@biomejs/cli-darwin-x64": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.2.7.tgz",
"integrity": "sha512-vsY4NhmxqgfLJufr9XUnC+yGUPJiXAc1mz6FcjaAmuIuLwfghN4uQO7hnW2AneGyoi2mNe9Jbvf6Qtq4AjzrFg==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.3.2.tgz",
"integrity": "sha512-jNMnfwHT4N3wi+ypRfMTjLGnDmKYGzxVr1EYAPBcauRcDnICFXN81wD6wxJcSUrLynoyyYCdfW6vJHS/IAoTDA==",
"cpu": [
"x64"
],
@ -120,9 +120,9 @@
}
},
"node_modules/@biomejs/cli-linux-arm64": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.2.7.tgz",
"integrity": "sha512-nUdco104rjV9dULi1VssQ5R/kX2jE/Z2sDjyqS+siV9sTQda0DwmEUixFNRCWvZJRRiZUWhgiDFJ4n7RowO8Mg==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.3.2.tgz",
"integrity": "sha512-amnqvk+gWybbQleRRq8TMe0rIv7GHss8mFJEaGuEZYWg1Tw14YKOkeo8h6pf1c+d3qR+JU4iT9KXnBKGON4klw==",
"cpu": [
"arm64"
],
@ -137,9 +137,9 @@
}
},
"node_modules/@biomejs/cli-linux-arm64-musl": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.2.7.tgz",
"integrity": "sha512-FrTwvKO/7t5HbVTvhlMOTOVQLAcR7r4O4iFQhEpZXUtBfosHqrX/JJlX7daPawoe14MDcCu9CDg0zLVpTuDvuQ==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.3.2.tgz",
"integrity": "sha512-2Zz4usDG1GTTPQnliIeNx6eVGGP2ry5vE/v39nT73a3cKN6t5H5XxjcEoZZh62uVZvED7hXXikclvI64vZkYqw==",
"cpu": [
"arm64"
],
@ -154,9 +154,9 @@
}
},
"node_modules/@biomejs/cli-linux-x64": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.2.7.tgz",
"integrity": "sha512-tPTcGAIEOOZrj2tQ7fdraWlaxNKApBw6l4In8wQQV1IyxnAexqi0hykHzKEX8hKKctf5gxGBfNCzyIvqpj4CFQ==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.3.2.tgz",
"integrity": "sha512-8BG/vRAhFz1pmuyd24FQPhNeueLqPtwvZk6yblABY2gzL2H8fLQAF/Z2OPIc+BPIVPld+8cSiKY/KFh6k81xfA==",
"cpu": [
"x64"
],
@ -171,9 +171,9 @@
}
},
"node_modules/@biomejs/cli-linux-x64-musl": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.2.7.tgz",
"integrity": "sha512-MnsysF5s/iLC5wnYvuMseOy+m8Pd4bWG1uwlVyy2AUbfjAVUgtbYbboc5wMXljFrDY7e6rLjLTR4S2xqDpGlQg==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.3.2.tgz",
"integrity": "sha512-gzB19MpRdTuOuLtPpFBGrV3Lq424gHyq2lFj8wfX9tvLMLdmA/R9C7k/mqBp/spcbWuHeIEKgEs3RviOPcWGBA==",
"cpu": [
"x64"
],
@ -188,9 +188,9 @@
}
},
"node_modules/@biomejs/cli-win32-arm64": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.2.7.tgz",
"integrity": "sha512-h5D1jhwA2b7cFXerYiJfXHSzzAMFFoEDL5Mc2BgiaEw0iaSgSso/3Nc6FbOR55aTQISql+IpB4PS7JoV26Gdbw==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.3.2.tgz",
"integrity": "sha512-lCruqQlfWjhMlOdyf5pDHOxoNm4WoyY2vZ4YN33/nuZBRstVDuqPPjS0yBkbUlLEte11FbpW+wWSlfnZfSIZvg==",
"cpu": [
"arm64"
],
@ -205,9 +205,9 @@
}
},
"node_modules/@biomejs/cli-win32-x64": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.2.7.tgz",
"integrity": "sha512-URqAJi0kONyBKG4V9NVafHLDtm6IHmF4qPYi/b6x7MD6jxpWeJiTCO6R5+xDlWckX2T/OGv6Yq3nkz6s0M8Ykw==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.3.2.tgz",
"integrity": "sha512-6Ee9P26DTb4D8sN9nXxgbi9Dw5vSOfH98M7UlmkjKB2vtUbrRqCbZiNfryGiwnPIpd6YUoTl7rLVD2/x1CyEHQ==",
"cpu": [
"x64"
],
@ -1412,9 +1412,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "24.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
"version": "24.9.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.2.tgz",
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
"dev": true,
"license": "MIT",
"peer": true,
@ -1536,9 +1536,9 @@
"license": "MIT"
},
"node_modules/baseline-browser-mapping": {
"version": "2.8.19",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.19.tgz",
"integrity": "sha512-zoKGUdu6vb2jd3YOq0nnhEDQVbPcHhco3UImJrv5dSkvxTc2pl2WjOPsjZXDwPDSl5eghIMuY3R6J9NDKF3KcQ==",
"version": "2.8.22",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.22.tgz",
"integrity": "sha512-/tk9kky/d8T8CTXIQYASLyhAxR5VwL3zct1oAoVTaOUHwrmsGnfbRwNdEq+vOl2BN8i3PcDdP0o4Q+jjKQoFbQ==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@ -1655,9 +1655,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001751",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001751.tgz",
"integrity": "sha512-A0QJhug0Ly64Ii3eIqHu5X51ebln3k4yTUkY1j8drqpWHVreg/VLijN48cZ1bYPiqOQuqpkIKnzr/Ul8V+p6Cw==",
"version": "1.0.30001752",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001752.tgz",
"integrity": "sha512-vKUk7beoukxE47P5gcVNKkDRzXdVofotshHwfR9vmpeFKxmI5PBpgOMC18LUJUA/DvJ70Y7RveasIBraqsyO/g==",
"dev": true,
"funding": [
{
@ -2072,9 +2072,9 @@
}
},
"node_modules/electron-to-chromium": {
"version": "1.5.240",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.240.tgz",
"integrity": "sha512-OBwbZjWgrCOH+g6uJsA2/7Twpas2OlepS9uvByJjR2datRDuKGYeD+nP8lBBks2qnB7bGJNHDUx7c/YLaT3QMQ==",
"version": "1.5.244",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.244.tgz",
"integrity": "sha512-OszpBN7xZX4vWMPJwB9illkN/znA8M36GQqQxi6MNy9axWxhOfJyZZJtSLQCpEFLHP2xK33BiWx9aIuIEXVCcw==",
"dev": true,
"license": "ISC"
},
@ -3138,9 +3138,9 @@
}
},
"node_modules/node-releases": {
"version": "2.0.26",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.26.tgz",
"integrity": "sha512-S2M9YimhSjBSvYnlr5/+umAnPHE++ODwt5e2Ij6FoX45HA/s4vHdkDx1eax2pAPeAOqu4s9b7ppahsyEFdVqQA==",
"version": "2.0.27",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz",
"integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==",
"dev": true,
"license": "MIT"
},

View File

@ -31,8 +31,8 @@
"swiped-events": "1.2.0"
},
"devDependencies": {
"@biomejs/biome": "2.2.7",
"@types/node": "~24.9.1",
"@biomejs/biome": "2.3.2",
"@types/node": "~24.9.2",
"browserslist": "~4.27.0",
"browserslist-to-esbuild": "~2.1.1",
"edge.js": "~6.3.0",

View File

@ -4,7 +4,7 @@ cov-core==1.15.0
black==25.9.0
pylint==4.0.2
splinter==0.21.0
selenium==4.37.0
selenium==4.38.0
Pallets-Sphinx-Themes==2.3.0
Sphinx==8.2.3 ; python_version >= '3.11'
Sphinx==8.1.3 ; python_version < '3.11'
@ -23,6 +23,6 @@ wlc==1.16.1
coloredlogs==15.0.1
docutils>=0.21.2
parameterized==0.9.0
granian[reload]==2.5.5
granian[reload]==2.5.6
basedpyright==1.32.1
types-lxml==2025.8.25

View File

@ -1 +1 @@
granian==2.5.5
granian==2.5.6

View File

@ -6,6 +6,11 @@
# - https://github.com/searxng/searxng/issues/5284
from __future__ import annotations
# msgspec: note that if using PEP 563 “postponed evaluation of annotations”
# (e.g. from __future__ import annotations) only the following spellings will
# work: https://jcristharif.com/msgspec/structs.html#class-variables
from typing import ClassVar
__all__ = [
"symbol_url",
"Temperature",
@ -266,8 +271,8 @@ class Temperature(msgspec.Struct, kw_only=True):
val: float
unit: TemperatureUnit
si_name: t.ClassVar[str] = "Q11579"
UNITS: t.ClassVar[tuple[TemperatureUnit]] = TEMPERATURE_UNITS
si_name: ClassVar[str] = "Q11579"
UNITS: ClassVar[tuple[TemperatureUnit]] = TEMPERATURE_UNITS
def __post_init__(self):
if self.unit not in self.UNITS:
@ -334,8 +339,8 @@ class Pressure(msgspec.Struct, kw_only=True):
val: float
unit: PressureUnit
si_name: t.ClassVar[str] = "Q44395"
UNITS: t.ClassVar[tuple[PressureUnit]] = PRESSURE_UNITS
si_name: ClassVar[str] = "Q44395"
UNITS: ClassVar[tuple[PressureUnit]] = PRESSURE_UNITS
def __post_init__(self):
if self.unit not in self.UNITS:
@ -387,8 +392,8 @@ class WindSpeed(msgspec.Struct, kw_only=True):
val: float
unit: WindSpeedUnit
si_name: t.ClassVar[str] = "Q182429"
UNITS: t.ClassVar[tuple[WindSpeedUnit]] = WIND_SPEED_UNITS
si_name: ClassVar[str] = "Q182429"
UNITS: ClassVar[tuple[WindSpeedUnit]] = WIND_SPEED_UNITS
def __post_init__(self):
if self.unit not in self.UNITS:
@ -432,8 +437,8 @@ class RelativeHumidity(msgspec.Struct):
val: float
# there exists only one unit (%) --> set "%" as the final value (constant)
unit: t.ClassVar[RelativeHumidityUnit] = "%"
UNITS: t.ClassVar[tuple[RelativeHumidityUnit]] = RELATIVE_HUMIDITY_UNITS
unit: ClassVar[RelativeHumidityUnit] = "%"
UNITS: ClassVar[tuple[RelativeHumidityUnit]] = RELATIVE_HUMIDITY_UNITS
def __post_init__(self):
if self.unit not in self.UNITS:
@ -476,15 +481,15 @@ class Compass(msgspec.Struct):
val: "float | int | CompassPoint"
unit: CompassUnit = "°"
UNITS: t.ClassVar[tuple[CompassUnit]] = COMPASS_UNITS
UNITS: ClassVar[tuple[CompassUnit]] = COMPASS_UNITS
TURN: t.ClassVar[float] = 360.0
TURN: ClassVar[float] = 360.0
"""Full turn (360°)"""
POINTS: t.ClassVar[tuple[CompassPoint]] = COMPASS_POINTS
POINTS: ClassVar[tuple[CompassPoint]] = COMPASS_POINTS
"""Compass points."""
RANGE: t.ClassVar[float] = TURN / len(POINTS)
RANGE: ClassVar[float] = TURN / len(POINTS)
"""Angle sector of a compass point"""
def __post_init__(self):
@ -506,14 +511,15 @@ class Compass(msgspec.Struct):
return self.val
raise ValueError(f"unknown unit: {unit}")
def point(self, azimuth: float | int) -> CompassPoint:
@classmethod
def point(cls, azimuth: float | int) -> CompassPoint:
"""Returns the compass point to an azimuth value."""
azimuth = azimuth % self.TURN
azimuth = azimuth % cls.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 - self.RANGE / 2
idx = int(azimuth // self.RANGE)
return self.POINTS[idx]
azimuth = azimuth - cls.RANGE / 2
idx = int(azimuth // cls.RANGE)
return cls.POINTS[idx]
def l10n(
self,