Skip to content

Commit 6fbd8ff

Browse files
committed
Update loading redirects.json.
1 parent d04fc10 commit 6fbd8ff

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/coltrane/config/redirects.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ def get_redirects() -> Generator[Redirect, None, None]:
2020
if not redirects_json_path.exists():
2121
return
2222

23-
with open(redirects_json_path) as f:
24-
paths = msgspec.json.decode(f.read_bytes(), type=Annotated[dict[str, str | Redirect], msgspec.Meta()])
23+
paths = msgspec.json.decode(
24+
redirects_json_path.read_bytes(), type=Annotated[dict[str, str | Redirect], msgspec.Meta()]
25+
)
2526

26-
for from_url, to_url in paths.items():
27-
if from_url.startswith("/"):
28-
from_url = from_url[1:] # noqa: PLW2901
27+
for from_url, to_url in paths.items():
28+
if from_url.startswith("/"):
29+
from_url = from_url[1:] # noqa: PLW2901
2930

30-
if isinstance(to_url, Redirect):
31-
redirect = to_url
32-
redirect.from_url = from_url
33-
else:
34-
redirect = Redirect(from_url=from_url, to_url=to_url, permanent=False)
31+
if isinstance(to_url, Redirect):
32+
redirect = to_url
33+
redirect.from_url = from_url
34+
else:
35+
redirect = Redirect(from_url=from_url, to_url=to_url, permanent=False)
3536

36-
yield redirect
37+
yield redirect

0 commit comments

Comments
 (0)