Skip to content

Commit f56fee4

Browse files
committed
Workaround for aiohttp
1 parent c51bc70 commit f56fee4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

patch/aiohttp310.patch

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- venv/lib/python3.12/site-packages/aiohttp/web_urldispatcher.py 2024-08-01 13:01:32
2+
+++ /tmp/web_urldispatcher.py 2024-08-01 22:37:19
3+
@@ -1132,15 +1132,7 @@
4+
def _get_resource_index_key(self, resource: AbstractResource) -> str:
5+
"""Return a key to index the resource in the resource index."""
6+
# strip at the first { to allow for variables
7+
- #return resource.canonical.partition("{")[0].rstrip("/") or "/"
8+
- if "{" in (index_key := resource.canonical):
9+
- # strip at the first { to allow for variables, and than
10+
- # rpartition at / to allow for variable parts in the path
11+
- # For example if the canonical path is `/core/locations{tail:.*}`
12+
- # the index key will be `/core` since index is based on the
13+
- # url parts split by `/`
14+
- index_key = index_key.partition("{")[0].rpartition("/")[0]
15+
- return index_key.rstrip("/") or "/"
16+
+ return resource.canonical.partition("{")[0].rstrip("/") or "/"
17+
18+
def index_resource(self, resource: AbstractResource) -> None:
19+
"""Add a resource to the resource index."""

scripts/tests_and_coverage.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pre-commit install
2626
pre-commit install-hooks
2727
pip install uv
2828
uv pip install -r requirements_test.txt -r requirements_commit.txt
29+
# TODO: Remove after update of aiohttp beyond 3.10.0
30+
uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" )
2931

3032
set +u
3133

0 commit comments

Comments
 (0)