Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #97 +/- ##
===========================================
- Coverage 100.00% 98.24% -1.76%
===========================================
Files 18 18
Lines 716 740 +24
Branches 74 77 +3
===========================================
+ Hits 716 727 +11
- Misses 0 10 +10
- Partials 0 3 +3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new trust_env option (and CLI flag) to allow aiohttp requests to honor environment-based proxy settings, addressing proxy-gated environments described in issue #96.
Changes:
- Add
trust_envparameter toAsyncZyteAPIandZyteAPI, and plumb it into session creation. - Add an opt-in
--trust-envCLI flag and pass it through to both the client and the underlyingaiohttpsession. - Extend test coverage for trust_env forwarding/behavior and close created sessions to avoid resource leaks.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
zyte_api/_sync.py |
Adds trust_env to the sync client and forwards it to the async client. |
zyte_api/_async.py |
Stores trust_env on the client and ensures created sessions inherit it. |
zyte_api/__main__.py |
Adds --trust-env flag and passes it into client/session creation; refactors input/output file handling. |
tests/test_utils.py |
Adds coverage for create_session(trust_env=...) and closes sessions. |
tests/test_sync.py |
Verifies sync client forwards trust_env into async client initialization. |
tests/test_main.py |
Verifies CLI run path passes trust_env through and parses --trust-env. |
tests/test_auth.py |
Adjusts subprocess env handling to avoid leaking auth env vars into CLI tests. |
tests/test_async.py |
Verifies async session/get paths inherit client trust_env. |
CHANGES.rst |
Documents the new opt-in trust_env parameter and CLI flag. |
Comments suppressed due to low confidence (1)
zyte_api/main.py:142
- The CLI now treats INPUT as a plain string path and later opens it with Path(...).open(). This changes behavior vs argparse.FileType: passing '-' will no longer read from stdin, and missing/unreadable files will raise an uncaught exception instead of a clean argparse error. Consider restoring FileType (or explicitly supporting '-' -> sys.stdin) and validating/opening failures via parser.error for a user-friendly CLI.
p.add_argument(
"INPUT",
help=(
"Path to an input file (see 'Command-line client > Input file' in "
"the docs for details)."
),
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for the fix @AdrianAtZyte Testing Results: Verified in proxy-gated environmentTested the Test Environment
Environment ValidationDirect DNS is broken (by design): Proxy path works (urllib respects env vars): Test ResultsWithout With The fix works as expected. Tested on behalf of #96. |
Fixes #96.