Skip to content

Commit 42176d9

Browse files
authored
Fix CI deprecation artifact upload/download (#205)
+ fix long scheme parsing + remove useless call on hasattr check (before pool memorize) + add note about using "multiplexed=True" along with requests-cache
2 parents d06129d + da9734d commit 42176d9

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

.github/workflows/publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
cd dist && echo "::set-output name=hashes::$(sha256sum * | base64 -w0)"
3939
4040
- name: "Upload dists"
41-
uses: "actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874"
41+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
4242
with:
4343
name: "dist"
4444
path: "dist/"
@@ -71,7 +71,7 @@ jobs:
7171

7272
steps:
7373
- name: "Download dists"
74-
uses: "actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395"
74+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
7575
with:
7676
name: "dist"
7777
path: "dist/"

.github/workflows/run-tests.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ jobs:
5353
run: |
5454
nox -s "test-${{ startsWith(matrix.python-version, 'pypy') && 'pypy' || matrix.python-version }}"
5555
- name: "Upload artifact"
56-
uses: "actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce"
56+
uses: "actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808"
5757
with:
58-
name: coverage-data
58+
name: coverage-data-${{ matrix.os }}-${{ matrix.nox-session }}-${{ matrix.python-version }}-${{ matrix.traefik-server }}
5959
path: ".coverage.*"
6060
if-no-files-found: error
6161

@@ -76,9 +76,10 @@ jobs:
7676
run: "python -m pip install --upgrade coverage"
7777

7878
- name: "Download artifact"
79-
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
79+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
8080
with:
81-
name: coverage-data
81+
pattern: coverage-data*
82+
merge-multiple: true
8283

8384
- name: "Combine & check coverage"
8485
run: |
@@ -87,7 +88,7 @@ jobs:
8788
python -m coverage report --ignore-errors --show-missing --fail-under=77
8889
8990
- name: "Upload report"
90-
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
91+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
9192
with:
9293
name: coverage-report
9394
path: htmlcov

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Niquests allows you to send HTTP requests extremely easily. There’s no need to
123123

124124
[![Downloads](https://img.shields.io/pypi/dm/niquests.svg)](https://pypistats.org/packages/niquests)
125125
[![Supported Versions](https://img.shields.io/pypi/pyversions/niquests.svg)](https://pypi.org/project/niquests)
126+
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9950/badge)](https://www.bestpractices.dev/projects/9950)
126127

127128
This project does not require any compilation toolchain. The HTTP/3 support is not enforced and installed if your platform can support it natively _(e.g. pre-built wheel available)_.
128129

docs/community/extensions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Quickstart to leverage its potential::
4444
for i in range(60):
4545
r = s.get('https://httpbin.org/delay/1')
4646

47+
.. warning:: Be advised that this extension nullify the advantage of using ``multiplexed=True`` within your Session constructor as is eagerly access the content.
48+
4749
responses
4850
---------
4951

src/niquests/adapters.py

+14-17
Original file line numberDiff line numberDiff line change
@@ -966,15 +966,14 @@ def early_response_hook(early_response: BaseHTTPResponse) -> None:
966966
# branch for urllib3.future 2.5+ with advanced conn/multiplexing scheduler/mapper. aka. TrafficPolice.
967967
# we are bypassing the PoolManager.request to directly invoke the concerned HttpPool, so we missed
968968
# a required call to TrafficPolice::memorize(...).
969-
if hasattr(self.poolmanager.pools, "memorize"):
970-
proxy = select_proxy(request.url, proxies)
969+
proxy = select_proxy(request.url, proxies)
971970

972-
if proxy is not None:
973-
self.proxy_manager[proxy].pools.memorize(resp_or_promise, conn)
974-
self.proxy_manager[proxy].pools.release()
975-
else:
976-
self.poolmanager.pools.memorize(resp_or_promise, conn)
977-
self.poolmanager.pools.release()
971+
if proxy is not None:
972+
self.proxy_manager[proxy].pools.memorize(resp_or_promise, conn)
973+
self.proxy_manager[proxy].pools.release()
974+
else:
975+
self.poolmanager.pools.memorize(resp_or_promise, conn)
976+
self.poolmanager.pools.release()
978977

979978
except (ProtocolError, OSError) as err:
980979
if "illegal header" in str(err).lower():
@@ -2062,18 +2061,16 @@ async def early_response_hook(early_response: BaseAsyncHTTPResponse) -> None:
20622061
multiplexed=multiplexed,
20632062
)
20642063

2065-
# branch for urllib3.future 2.5+ with advanced conn/multiplexing scheduler/mapper. aka. TrafficPolice.
20662064
# we are bypassing the PoolManager.request to directly invoke the concerned HttpPool, so we missed
20672065
# a required call to TrafficPolice::memorize(...).
2068-
if hasattr(self.poolmanager.pools, "memorize"):
2069-
proxy = select_proxy(request.url, proxies)
2066+
proxy = select_proxy(request.url, proxies)
20702067

2071-
if proxy is not None:
2072-
self.proxy_manager[proxy].pools.memorize(resp_or_promise, conn)
2073-
self.proxy_manager[proxy].pools.release()
2074-
else:
2075-
self.poolmanager.pools.memorize(resp_or_promise, conn)
2076-
self.poolmanager.pools.release()
2068+
if proxy is not None:
2069+
self.proxy_manager[proxy].pools.memorize(resp_or_promise, conn)
2070+
self.proxy_manager[proxy].pools.release()
2071+
else:
2072+
self.poolmanager.pools.memorize(resp_or_promise, conn)
2073+
self.poolmanager.pools.release()
20772074

20782075
except (ProtocolError, OSError) as err:
20792076
if "illegal header" in str(err).lower():

src/niquests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ def _deepcopy_ci(o: ConnectionInfo | None) -> ConnectionInfo | None:
12011201
return n
12021202

12031203

1204-
def parse_scheme(url: str, default: str | None = None, max_length: int = 9) -> str:
1204+
def parse_scheme(url: str, default: str | None = None, max_length: int = 11) -> str:
12051205
"""We tend to extract url scheme often enough, but we were crazy
12061206
enough to use urlparse for it...! We were wasting precious CPU cycles.
12071207
Return used scheme url, lowercased."""

tests/test_requests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_entry_points(self):
8686
(MissingSchema, "hiwpefhipowhefopw"),
8787
(InvalidSchema, "localhost:3128"),
8888
(MissingSchema, "localhost.localdomain:3128/"),
89-
(MissingSchema, "10.122.1.1:3128/"),
89+
(InvalidSchema, "10.122.1.1:3128/"),
9090
(InvalidURL, "http://"),
9191
(InvalidURL, "http://*example.com"),
9292
(InvalidURL, "http://.example.com"),

0 commit comments

Comments
 (0)