Repository: searxng/searxng

Issue:
Bump typing-extensions from 4.9.0 to 4.10.0
Bumps [typing-extensions](https://github.com/python/typing_extensions) from 4.9.0 to 4.10.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/python/typing_extensions/releases">typing-extensions's releases</a>.</em></p>
<blockquote>
<h2>4.10.0</h2>
<h1>Release 4.10.0 (February 25, 2024)</h1>
<p>This feature release adds support for PEP 728 (TypedDict with extra
items) and PEP 742 (<code>TypeIs</code>).</p>
<p>There are no changes since 4.10.0rc1.</p>
<h2>4.10.0rc1</h2>
<h1>Release 4.10.0rc1 (February 17, 2024)</h1>
<ul>
<li>Add support for PEP 728, supporting the <code>closed</code> keyword argument and the
special <code>__extra_items__</code> key for TypedDict. Patch by Zixuan James Li.</li>
<li>Add support for PEP 742, adding <code>typing_extensions.TypeIs</code>. Patch
by Jelle Zijlstra.</li>
<li>Drop runtime error when a read-only <code>TypedDict</code> item overrides a mutable
one. Type checkers should still flag this as an error. Patch by Jelle
Zijlstra.</li>
<li>Speedup <code>issubclass()</code> checks against simple runtime-checkable protocols by
around 6% (backporting <a href="https://redirect.github.com/python/cpython/pull/112717">python/cpython#112717</a>, by Alex
Waygood).</li>
<li>Fix a regression in the implementation of protocols where <code>typing.Protocol</code>
classes that were not marked as <code>@runtime_checkable</code> would be unnecessarily
introspected, potentially causing exceptions to be raised if the protocol had
problematic members. Patch by Alex Waygood, backporting
<a href="https://redirect.github.com/python/cpython/pull/113401">python/cpython#113401</a>.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/python/typing_extensions/blob/main/CHANGELOG.md">typing-extensions's changelog</a>.</em></p>
<blockquote>
<h1>Release 4.10.0 (February 24, 2024)</h1>
<p>This feature release adds support for PEP 728 (TypedDict with extra
items) and PEP 742 (<code>TypeIs</code>).</p>
<p>There are no changes since 4.10.0rc1.</p>
<h1>Release 4.10.0rc1 (February 17, 2024)</h1>
<ul>
<li>Add support for PEP 728, supporting the <code>closed</code> keyword argument and the
special <code>__extra_items__</code> key for TypedDict. Patch by Zixuan James Li.</li>
<li>Add support for PEP 742, adding <code>typing_extensions.TypeIs</code>. Patch
by Jelle Zijlstra.</li>
<li>Drop runtime error when a read-only <code>TypedDict</code> item overrides a mutable
one. Type checkers should still flag this as an error. Patch by Jelle
Zijlstra.</li>
<li>Speedup <code>issubclass()</code> checks against simple runtime-checkable protocols by
around 6% (backporting <a href="https://redirect.github.com/python/cpython/pull/112717">python/cpython#112717</a>, by Alex
Waygood).</li>
<li>Fix a regression in the implementation of protocols where <code>typing.Protocol</code>
classes that were not marked as <code>@runtime_checkable</code> would be unnecessarily
introspected, potentially causing exceptions to be raised if the protocol had
problematic members. Patch by Alex Waygood, backporting
<a href="https://redirect.github.com/python/cpython/pull/113401">python/cpython#113401</a>.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/python/typing_extensions/commit/ed81f2b2043f60b0c159914e264e127f5d0b4cda"><code>ed81f2b</code></a> Prepare release 4.10.0 (<a href="https://redirect.github.com/python/typing_extensions/issues/343">#343</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/06b23e3f05fd0f929dbaea17ae51621dcc8434ab"><code>06b23e3</code></a> Release 4.10.0rc1 (<a href="https://redirect.github.com/python/typing_extensions/issues/340">#340</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/b7bf949d669dbe19537f7608e00f7b8368fdfb39"><code>b7bf949</code></a> Add support for PEP 728 (<a href="https://redirect.github.com/python/typing_extensions/issues/329">#329</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/9f040ab8c6f859e8ce956331b496e6a98a33e6f6"><code>9f040ab</code></a> Fix changelog entry and <strong>mutable_keys</strong> tracking for PEP 705 (<a href="https://redirect.github.com/python/typing_extensions/issues/334">#334</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/566e01e7a798abfcf88849814918fd8413b8d18b"><code>566e01e</code></a> Add support for TypeIs (PEP 742) (<a href="https://redirect.github.com/python/typing_extensions/issues/330">#330</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/d6c50f585c386490d38ad6b8ce5543aed6e633a2"><code>d6c50f5</code></a> Drop runtime error in PEP 705 implementation (<a href="https://redirect.github.com/python/typing_extensions/issues/333">#333</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/ff530f50e2e1440e870dfecd2f59a5ae9d2a4244"><code>ff530f5</code></a> Update GitHub Actions versions (<a href="https://redirect.github.com/python/typing_extensions/issues/332">#332</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/05ffab5fda8510249ec10bc138c72678e3f6d2d9"><code>05ffab5</code></a> Catch a deprecation warning on Python 3.13 (<a href="https://redirect.github.com/python/typing_extensions/issues/331">#331</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/69b48c377a2a1286c57059e66c47d386374c46c2"><code>69b48c3</code></a> Fix display of TypedDict.<strong>readonly_keys</strong> (<a href="https://redirect.github.com/python/typing_extensions/issues/328">#328</a>)</li>
<li><a href="https://github.com/python/typing_extensions/commit/004b893ddce2a5743d9a4de3a97ef5c48882d384"><code>004b893</code></a> Backport recent improvements to the implementation of <code>Protocol</code> (<a href="https://redirect.github.com/python/typing_extensions/issues/324">#324</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/python/typing_extensions/compare/4.9.0...4.10.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typing-extensions&package-manager=pip&previous-version=4.9.0&new-version=4.10.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Discussion:
Not sure we really need this extension any longer / we should consider to remove it:

- https://github.com/search?q=repo%3Asearxng%2Fsearxng%20typing_extensions&type=code
There are two refs:

https://github.com/search?q=repo%3Asearxng%2Fsearxng%20typing_extensions&type=code

https://github.com/searxng/searxng/blob/858b2071df818eddafe835e2d1342fab6feb28dd/searx/enginelib/traits.py#L18

https://github.com/searxng/searxng/blob/858b2071df818eddafe835e2d1342fab6feb28dd/searx/search/checker/background.py#L12
> There are two refs:

- `Literal` is supported by [py3.8](https://docs.python.org/3.8/library/typing.html#typing.Literal)
- `TypedDict` is supported by [py3.9](https://docs.python.org/3.9/library/typing.html#relevant-peps)
- `Self` is supported by [py3.11](https://docs.python.org/3.11/library/typing.html#typing.Self) .. but can be replaced by `Self = TypeVar("Self", bound="Foo")`

I think we can at least reduce the usage of the `typing_extensions` where it is possible .. with the aim to drop this requirement at one day. 
We can/should more often use [forward references](https://peps.python.org/pep-0484/#forward-references) .. this can help to avoid unneeded (and potential cyclic) imports .. additionally we can replace `Self` by  forward references.

Resolving patch:
diff --git a/searx/enginelib/traits.py b/searx/enginelib/traits.py
--- a/searx/enginelib/traits.py
+++ b/searx/enginelib/traits.py
@@ -14,8 +14,7 @@
 import json
 import dataclasses
 import types
-from typing import Dict, Iterable, Union, Callable, Optional, TYPE_CHECKING
-from typing_extensions import Literal, Self
+from typing import Dict, Literal, Iterable, Union, Callable, Optional, TYPE_CHECKING
 
 from searx import locales
 from searx.data import data_dir, ENGINE_TRAITS
@@ -136,7 +135,7 @@ def copy(self):
         return EngineTraits(**dataclasses.asdict(self))
 
     @classmethod
-    def fetch_traits(cls, engine: Engine) -> Union[Self, None]:
+    def fetch_traits(cls, engine: Engine) -> Union['EngineTraits', None]:
         """Call a function ``fetch_traits(engine_traits)`` from engines namespace to fetch
         and set properties from the origin engine in the object ``engine_traits``.  If
         function does not exists, ``None`` is returned.
@@ -204,7 +203,7 @@ def save_data(self):
             json.dump(self, f, indent=2, sort_keys=True, cls=EngineTraitsEncoder)
 
     @classmethod
-    def from_data(cls) -> Self:
+    def from_data(cls) -> 'EngineTraitsMap':
         """Instantiate :class:`EngineTraitsMap` object from :py:obj:`ENGINE_TRAITS`"""
         obj = cls()
         for k, v in ENGINE_TRAITS.items():
@@ -212,7 +211,7 @@ def from_data(cls) -> Self:
         return obj
 
     @classmethod
-    def fetch_traits(cls, log: Callable) -> Self:
+    def fetch_traits(cls, log: Callable) -> 'EngineTraitsMap':
         from searx import engines  # pylint: disable=cyclic-import, import-outside-toplevel
 
         names = list(engines.engines)
diff --git a/searx/search/checker/background.py b/searx/search/checker/background.py
--- a/searx/search/checker/background.py
+++ b/searx/search/checker/background.py
@@ -8,8 +8,7 @@
 import threading
 import os
 import signal
-from typing import Dict, Union, List, Any, Tuple, Optional
-from typing_extensions import TypedDict, Literal
+from typing import Any, Dict, List, Literal, Optional, Tuple, TypedDict, Union
 
 import redis.exceptions
 


Test patch: