Skip to content

Commit 3a8651a

Browse files
committed
ci: add requests compatiblity check
1 parent d69dac1 commit 3a8651a

File tree

5 files changed

+112
-13
lines changed

5 files changed

+112
-13
lines changed

.github/workflows/deps.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Check Compability
2+
on:
3+
- pull_request
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
7+
env:
8+
UV_SYSTEM_PYTHON: true
9+
jobs:
10+
check-requests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
requests-version:
16+
- '2.32.3'
17+
- '2.32.2'
18+
- '2.31.0'
19+
- '2.30.0'
20+
- '2.29.0'
21+
- '2.28.2'
22+
- '2.28.1'
23+
- '2.28.0'
24+
- '2.27.1'
25+
- '2.27.0'
26+
- '2.26.0'
27+
- '2.25.1'
28+
- '2.25.0'
29+
- '2.24.0'
30+
- '2.23.0'
31+
- '2.22.0'
32+
- '2.21.0'
33+
- '2.20.1'
34+
- '2.20.0'
35+
- '2.19.1'
36+
- '2.19.0'
37+
- '2.18.4'
38+
- '2.18.3'
39+
- '2.18.2'
40+
- '2.18.1'
41+
- '2.18.0'
42+
- '2.17.3'
43+
- '2.17.2'
44+
- '2.17.1'
45+
- '2.17.0'
46+
- '2.16.5'
47+
- '2.16.4'
48+
- '2.16.3'
49+
- '2.16.2'
50+
- '2.16.1'
51+
- '2.16.0'
52+
- '2.15.1'
53+
- '2.15.0'
54+
- '2.14.2'
55+
- '2.14.1'
56+
- '2.14.0'
57+
- '2.13.0'
58+
- '2.12.5'
59+
- '2.12.4'
60+
- '2.12.3'
61+
- '2.12.2'
62+
- '2.12.1'
63+
- '2.12.0'
64+
- '2.11.1'
65+
- '2.11.0'
66+
- '2.10.0'
67+
- '2.9.2'
68+
- '2.9.1'
69+
- '2.9.0'
70+
- '2.8.1'
71+
- '2.8.0'
72+
- '2.7.0'
73+
- '2.6.2'
74+
- '2.6.1'
75+
- '2.6.0'
76+
- '2.5.3'
77+
- '2.5.2'
78+
- '2.5.1'
79+
- '2.5.0'
80+
- '2.4.3'
81+
- '2.4.2'
82+
- '2.4.1'
83+
- '2.4.0'
84+
- '2.3.0'
85+
- '2.2.1'
86+
- '2.2.0'
87+
- '2.1.0'
88+
- '2.0.1'
89+
- '2.0.0'
90+
steps:
91+
- uses: actions/checkout@v4
92+
- uses: actions/setup-python@v5
93+
with:
94+
python-version: 3.x
95+
check-latest: true
96+
cache: 'pip'
97+
- run: make dev
98+
- run: make deps
99+
- run: uv pip install requests==${{ matrix.requests-version }}
100+
- run: make test

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
]
2121
dynamic = ["version"]
2222
dependencies = [
23-
"requests>=2.31.0,<3",
23+
"requests>=2,<3",
2424
"packaging",
2525
"typing-extensions"
2626
]

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
requests==2.32.2
2-
packaging==24.1
3-
typing-extensions==4.12.2
1+
requests
2+
packaging
3+
typing-extensions

src/posit/connect/hooks.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import json
12
import warnings
23
from http.client import responses
34

4-
from requests import JSONDecodeError, Response
5+
import requests
6+
from requests import Response
57

68
from .errors import ClientError
79

@@ -14,11 +16,10 @@ def handle_errors(response: Response, *args, **kwargs) -> Response:
1416
message = data["error"]
1517
payload = data.get("payload")
1618
http_status = response.status_code
17-
http_status_message = responses[http_status]
19+
http_status_message = responses.get(http_status, "Unknown status")
1820
raise ClientError(error_code, message, http_status, http_status_message, payload)
19-
except JSONDecodeError:
20-
# No JSON error message from Connect, so just raise
21-
response.raise_for_status()
21+
finally:
22+
response.raise_for_status() # Raise if no JSON error is available
2223
return response
2324

2425

tests/posit/connect/test_hooks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ def test_client_error():
2323
with pytest.raises(ClientError):
2424
handle_errors(response)
2525

26-
27-
@patch("posit.connect.hooks.JSONDecodeError")
28-
def test_client_error_without_payload(JSONDecodeError):
26+
def test_client_error_without_payload():
2927
response = Mock()
3028
response.status_code = 404
31-
response.json = Mock(side_effect=JSONDecodeError())
29+
response.json = Mock(side_effect=Exception())
3230
response.raise_for_status = Mock(side_effect=Exception())
3331
with pytest.raises(Exception):
3432
handle_errors(response)

0 commit comments

Comments
 (0)