Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make code compatible with python3.13
Browse files Browse the repository at this point in the history
OlegZv committed Dec 18, 2024
1 parent 21c1e94 commit 4e305fc
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions fastapi_versionizer/versionizer.py
Original file line number Diff line number Diff line change
@@ -342,11 +342,13 @@ def _add_route_to_router(
return router.add_api_websocket_route(**kwargs)
except TypeError as e:
e_str = str(e)
key_start = e_str.index("'") + 1
key_end = e_str.rindex("'")
kwargs.pop(e_str[key_start:key_end])
error_parts = e_str.split("'")
if len(error_parts) < 2:
raise RuntimeError(f'unknown type error: {e_str}')
key_to_remove = error_parts[1]
kwargs.pop(key_to_remove)

raise Exception('Failed to add route')
raise RuntimeError('Failed to add route')

def _strip_routes(self) -> None:
paths_to_keep = []
2 changes: 1 addition & 1 deletion tests/test_with_static_file_mount.py
Original file line number Diff line number Diff line change
@@ -18,4 +18,4 @@ def test_with_static_file_mount_example(self) -> None:

# Check that a static mount before instantiating Versionizer will not work
self.assertEqual('{"detail":"Not Found"}',
test_client.get('/examples-not-working/with_static_file_mount.py').text)
test_client.get('/examples-not-working/with_static_file_mount.py').text)

0 comments on commit 4e305fc

Please sign in to comment.