Skip to content

LITE-33583: Runtime floor to Python 3.10 and modernize http toolchain#86

Merged
pcaro merged 4 commits into
masterfrom
cr/LITE-deps-bump-py310
Jul 2, 2026
Merged

LITE-33583: Runtime floor to Python 3.10 and modernize http toolchain#86
pcaro merged 4 commits into
masterfrom
cr/LITE-deps-bump-py310

Conversation

@pcaro

@pcaro pcaro commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Raise the runtime floor to Python 3.10 (verified on 3.10 and 3.12) and modernize the HTTP toolchain.

  • python >=3.10,<4 (drop 3.9 from deps + CI matrix)
  • httpx >=0.28, pytest-httpx >=0.35, inflect >=7
  • dev: pytest >=8,<9, pytest-asyncio >=0.24,<2, pytest-cov <7
  • poetry.lock re-resolved → httpx 0.28.1, pytest-httpx 0.35.0, pytest 8.4.2, pytest-asyncio 1.4.0

Why this is one change

We like to keep "updated" (now we support even 3.10 ) connect-cli and this dependency had pinned oudated versions.

API changes absorbed (pytest-httpx 0.31+ / httpx 0.28)

Adapted connect/client/testing/fluent.py:

  • HTTPXMock() now requires _HTTPXMockOptions. Constructed with assert_all_requests_were_expected=False + can_send_already_matched_responses=True to preserve the previous mocker semantics (one registered response answers retried requests — the client retries on 5xx).
  • reset() no longer asserts; call _assert_options() explicitly, gated by success, to keep failing on unrequested mocks.
  • match_content now serializes JSON with compact separators to match httpx 0.28's compact request-body serialization.
  • test_execute_error_with_reason (native httpx_mock fixture, retries on 500) marked with matching @pytest.mark.httpx_mock(...) options.

Verification

All 399 tests pass on Python 3.10 and 3.12. flake8 clean on changed files.

@pcaro pcaro force-pushed the cr/LITE-deps-bump-py310 branch from b52dfd0 to 27c6c0b Compare June 30, 2026 13:53
@pcaro pcaro changed the base branch from cr/LITE-34447-drop-importlib-metadata to master June 30, 2026 13:53
@pcaro pcaro force-pushed the cr/LITE-deps-bump-py310 branch from 820ce32 to c0afad9 Compare July 1, 2026 09:36
…cker

Raise the runtime floor to Python 3.10 (verified on 3.10 and 3.12) and
modernize the HTTP toolchain:

  - python >=3.10,<4 (drop 3.9 from deps and CI matrix)
  - httpx >=0.28, pytest-httpx >=0.35, inflect >=7
  - dev: pytest >=8,<9, pytest-asyncio >=0.24,<2, pytest-cov <7

pytest-httpx >=0.35 (which pulls httpx 0.28) is the only path to httpx
0.28, and it forces the pytest/pytest-asyncio bumps transitively. Its
0.31+ API changes break the async mocker, so adapt it:

  - HTTPXMock now requires _HTTPXMockOptions; construct it with
    can_send_already_matched_responses=True so a single registered
    response answers the ConnectClient's retried requests. The strict
    assert_all_requests_were_expected default is kept, so an unmocked
    request fails the test.
  - reset() no longer performs assertions; call _assert_options()
    explicitly, gated by success, to keep failing on unrequested mocks.
  - match_content now serializes JSON with compact separators to match
    httpx 0.28's compact request-body serialization.

Mark test_execute_error_with_reason (native httpx_mock fixture, retries
on 500) with the matching httpx_mock options. All tests pass.
@pcaro pcaro force-pushed the cr/LITE-deps-bump-py310 branch 2 times, most recently from dd2d0c6 to 925d1d0 Compare July 1, 2026 09:49
connect/client/fluent.py imported `Proxy` from httpx._config and
`get_environment_proxies` from httpx._utils. Both are private httpx APIs
that can change or vanish on any minor release, and the import happens at
module load, so a break would take down the whole client, not just proxy
support.

Reimplement the environment proxy discovery locally as
_get_environment_proxies() on top of stdlib urllib.request.getproxies()
and ipaddress, faithfully porting httpx 0.28's algorithm: http/https/all
schemes (normalizing bare host:port to a http:// URL) and NO_PROXY
handling for domains, IPv4, IPv6, localhost, explicit-scheme hosts, and
the NO_PROXY=* global bypass. Use the public httpx.Proxy instead of the
private one.

Add tests for this previously untested logic (scheme normalization, each
NO_PROXY host form, and the wildcard bypass). All 407 tests pass.
@pcaro pcaro force-pushed the cr/LITE-deps-bump-py310 branch from 925d1d0 to 22e568f Compare July 1, 2026 10:01
@pcaro pcaro changed the title build(deps): drop Python 3.9, bump httpx/pytest-httpx, adapt async mocker build(deps): Runtime floor to Python 3.10 and modernize http toolchain Jul 1, 2026
@pcaro pcaro changed the title build(deps): Runtime floor to Python 3.10 and modernize http toolchain LITE-33583: Runtime floor to Python 3.10 and modernize http toolchain Jul 1, 2026
@pcaro pcaro marked this pull request as ready for review July 1, 2026 10:22
The install section still stated Python 3.9 as the minimum. Python 3.9
support was dropped on this branch (pyproject.toml now requires >=3.10),
so align the README with the actual requirement.

@qarlosh qarlosh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes. Details in the inline comments.

Comment thread connect/client/testing/fluent.py
Comment thread connect/client/testing/fluent.py
Comment thread connect/client/testing/fluent.py
Address PR review on the httpx 0.28 / pytest-httpx 0.35 bump.

- match_content now mirrors httpx 0.28's request-body serialization
  exactly by adding ensure_ascii=False and allow_nan=False. Without
  them a non-ASCII match_body serialized to \uXXXX escapes while httpx
  sends raw UTF-8, so the mock silently failed to match.
- Pin an upper bound pytest-httpx >=0.35,<1. It is a runtime dependency
  (connect.client.testing ships the mocker and a pytest11 plugin) that
  relies on private pytest_httpx API (_HTTPXMockOptions, _assert_options),
  so an unbounded minor bump could break downstream test suites.
- Add test_create_match_non_ascii_body and test_unrequested_mock_fails
  to cover the non-ASCII matching and the reset() assertion path, which
  previously had no coverage.
@pcaro pcaro requested a review from qarlosh July 1, 2026 14:52
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@pcaro pcaro merged commit e167136 into master Jul 2, 2026
5 checks passed
pcaro added a commit to cloudblue/connect-cli that referenced this pull request Jul 2, 2026
connect-openapi-client 35.0 dropped its importlib-metadata<7 pin
(cloudblue/connect-python-openapi-client#86), which was the only thing
blocking interrogatio 2.4 (which needs importlib-metadata>=8.5).

  connect-openapi-client  >=29   -> >=35    (34.0 -> 35.0)
  interrogatio            ^2.3.1 -> ^2.4     (2.3.1 -> 2.4.0)
  importlib-metadata      6.x    -> 8.9.0
  httpx                          -> 0.28.1   (pulled by client 35)
  pytest-httpx            0.29.0 -> 0.35.0   (idem)
  sniffio                 removed            (no longer required)

Full suite: 715 passed.
pcaro added a commit to cloudblue/connect-cli that referenced this pull request Jul 2, 2026
Clean, targeted dependency refresh on top of current master, replacing
the stale bot PR #248. Mirrors the sibling bump in
cloudblue/connect-python-openapi-client#86.

Test toolchain:
  pytest      7.2.2  -> 8.4.2
  pytest-cov  2.12.1 -> 6.3.0
  coverage    5.5    -> 7.14.3
  responses   0.20.0 -> 0.26.1

pytest 8 changed collection ordering, exposing a latent isolation bug:
tests/plugins/play/test_play_commands.py deletes and reimports
connect.cli.ccli, so test_ccli.py's module-level 'from ... import main'
bound to a stale module object that mocker.patch never touched. Fixed by
importing main inside each test.

Lint toolchain:
  flake8             5.0.4   -> 7.3.0
  flake8-bugbear     22.12.6 -> 25.11.29
  flake8-commas      2.1.0   -> 4.0.0
  flake8-isort       5.0.3   -> 6.1.2
  flake8-broken-line 0.5.0   -> 1.0.0

Only bugbear codes are enforced (select = "B"); bugbear 25 adds B017,
which flagged a broad pytest.raises(Exception) in test_http.py masking
the real ValueError; narrowed it.

Runtime deps:
  connect-openapi-client  >=29 -> >=35   (34.0 -> 35.0)
  interrogatio            2.3.1 -> 2.4.0
  iso3166                 1.0.1 -> 2.1.1
  phonenumbers            8.13.55 -> 9.0.33
  poetry-core             1.9.1 -> 2.4.1
  click                   8.3.1 -> 8.4.2
  requests                2.32.5 -> 2.34.2

openapi-client 35.0 dropped its importlib-metadata<7 pin (#86), which
unblocked interrogatio 2.4 (needs importlib-metadata>=8.5); that also
pulls httpx 0.28.1 / pytest-httpx 0.35.0 and drops sniffio.

Lint/format stack (black) and runtime majors gated upstream
(eaas-core, reports-core, rich via markdown-renderer) are left untouched.
Full suite: 715 passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants