Skip to content

fix: accept str addresses in ServiceInfo.addresses under cython - #1836

Merged
bdraco merged 2 commits into
masterfrom
fix-addresses-setter-str
Aug 28, 2026
Merged

bdraco merged 2 commits into
masterfrom
fix-addresses-setter-str

Conversation

@bdraco

@bdraco bdraco commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Under the Cython 3.3 build, assigning ServiceInfo.addresses with string addresses raises TypeError: Expected bytes, got str; the pure Python build still accepts them. This restores the setter contract, which has always advertised str as well as bytes.

Details

  • The setter and the addresses constructor kwarg were annotated list[bytes]; Cython 3.3 uses the element type to narrow the loop variable, so any non bytes item is rejected before cached_ip_addresses ever sees it. The annotation is now Sequence[bytes | str], matching what cached_ip_addresses accepts.
  • ip_bytes_and_scope_to_address already handled str at runtime; its parameter type is widened to match so mypy is satisfied. Its .pxd declares the argument as object, so no .pxd change is needed.
  • The runtime body of the setter is unchanged.

Test plan

  • New parametrized test in tests/services/test_info.py covering str, bytes, and mixed lists for both the setter and the constructor kwarg, plus a TypeError case for an invalid address
  • tests/services/test_info.py, tests/utils/test_ipaddress.py and tests/test_core.py pass on the Cython build (REQUIRE_CYTHON=1 poetry install)
  • pre-commit green

@codspeed

codspeed Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing fix-addresses-setter-str (2033337) with master (b3634f2)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (9dc8bf8) during the generation of this report, so b3634f2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.87%. Comparing base (b3634f2) to head (2033337).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1836   +/-   ##
=======================================
  Coverage   99.87%   99.87%           
=======================================
  Files          33       33           
  Lines        3883     3883           
  Branches      567      567           
=======================================
  Hits         3878     3878           
  Misses          3        3           
  Partials        2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco
bdraco marked this pull request as ready for review August 28, 2026 23:28
@bdraco bdraco changed the title fix: accept str and int addresses in ServiceInfo.addresses under cython fix: accept str addresses in ServiceInfo.addresses under cython Aug 28, 2026
@bdraco
bdraco marked this pull request as draft August 28, 2026 23:31
@bdraco
bdraco marked this pull request as ready for review August 28, 2026 23:32
@bdraco
bdraco merged commit c0b2d50 into master Aug 28, 2026
35 checks passed
@bdraco
bdraco deleted the fix-addresses-setter-str branch August 28, 2026 23:33
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.

1 participant