From 5014139ed41d0ecdebc232a7d1779eb55d56f2a0 Mon Sep 17 00:00:00 2001 From: OlegZv Date: Tue, 17 Dec 2024 23:21:15 -0500 Subject: [PATCH 1/4] deps: Add 3.13 tests and these will fail --- .github/workflows/pull-request.yml | 14 +++++++------- requirements.dev.txt | 7 +++---- setup.py | 4 +++- tests/test_with_static_file_mount.py | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1c6d3bf..3dac528 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,10 +16,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9', '3.10', '3.11' ] + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5.3.0 with: python-version: ${{ matrix.python-version }} - run: make install-dev @@ -29,10 +29,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9', '3.10', '3.11' ] + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5.3.0 with: python-version: ${{ matrix.python-version }} - run: make install-dev @@ -42,10 +42,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9', '3.10', '3.11' ] + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5.3.0 with: python-version: ${{ matrix.python-version }} - run: make install-dev @@ -55,7 +55,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5.30 with: python-version: 3.11 - run: pip install safety==2.3.5 diff --git a/requirements.dev.txt b/requirements.dev.txt index 357588b..bc5f401 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -7,13 +7,12 @@ flake8-eradicate==1.4.0 flake8-length==0.3.1 flake8-quotes==3.3.2 flake8-use-fstring==1.4 -pytest==7.0.1 +pytest==8.3.4 mypy==1.4.1 pre-commit==2.21.0 -pytest==7.0.1 -pytest-cov==4.1.0 +pytest-cov==6.0.0 safety==2.3.5 twine==3.8.0 types-setuptools==65.6.0.2 -httpx==0.22.0 +httpx==0.28.1 uvicorn==0.16.0 diff --git a/setup.py b/setup.py index 30bf688..454df82 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,9 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11' + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13' ], install_requires=requirements_list, python_requires='>=3.8' diff --git a/tests/test_with_static_file_mount.py b/tests/test_with_static_file_mount.py index 859f0fa..1578967 100644 --- a/tests/test_with_static_file_mount.py +++ b/tests/test_with_static_file_mount.py @@ -17,5 +17,5 @@ def test_with_static_file_mount_example(self) -> None: self.assertEqual(expected, test_client.get('/examples/with_static_file_mount.py').text) # Check that a static mount before instantiating Versionizer will not work - self.assertEquals('{"detail":"Not Found"}', + self.assertEqual('{"detail":"Not Found"}', test_client.get('/examples-not-working/with_static_file_mount.py').text) From 58352adf95694ddfb608af5bd728ee5153e357fc Mon Sep 17 00:00:00 2001 From: OlegZv Date: Tue, 17 Dec 2024 23:24:04 -0500 Subject: [PATCH 2/4] fix: Update action version typo --- .github/workflows/deploy.yml | 2 +- .github/workflows/pull-request.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b3a0fa5..3b290ed 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5.3.0 with: python-version: '3.8' - run: make install-dev diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3dac528..9ffd588 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -55,7 +55,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5.30 + - uses: actions/setup-python@v5.3.0 with: python-version: 3.11 - run: pip install safety==2.3.5 From 21c1e94ed38d01e014f791e3e4eed2884d1a0eed Mon Sep 17 00:00:00 2001 From: OlegZv Date: Tue, 17 Dec 2024 23:27:20 -0500 Subject: [PATCH 3/4] deps: Downgrade pytest-cov to v5 (v6 dropped python3.8) --- requirements.dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.dev.txt b/requirements.dev.txt index bc5f401..2e3dda3 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -10,7 +10,7 @@ flake8-use-fstring==1.4 pytest==8.3.4 mypy==1.4.1 pre-commit==2.21.0 -pytest-cov==6.0.0 +pytest-cov==5.0.0 safety==2.3.5 twine==3.8.0 types-setuptools==65.6.0.2 From 4e305fc88053aa5147b9cc274a774c7ab19cbe6e Mon Sep 17 00:00:00 2001 From: OlegZv Date: Tue, 17 Dec 2024 23:46:55 -0500 Subject: [PATCH 4/4] fix: Make code compatible with python3.13 --- fastapi_versionizer/versionizer.py | 10 ++++++---- tests/test_with_static_file_mount.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fastapi_versionizer/versionizer.py b/fastapi_versionizer/versionizer.py index 639b633..e3c6c8f 100644 --- a/fastapi_versionizer/versionizer.py +++ b/fastapi_versionizer/versionizer.py @@ -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 = [] diff --git a/tests/test_with_static_file_mount.py b/tests/test_with_static_file_mount.py index 1578967..d807cfb 100644 --- a/tests/test_with_static_file_mount.py +++ b/tests/test_with_static_file_mount.py @@ -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)