Skip to content

fix: improve type safety and error handling#12254

Open
N3XT3R1337 wants to merge 1 commit intoaio-libs:masterfrom
N3XT3R1337:fix/improve-code-quality
Open

fix: improve type safety and error handling#12254
N3XT3R1337 wants to merge 1 commit intoaio-libs:masterfrom
N3XT3R1337:fix/improve-code-quality

Conversation

@N3XT3R1337
Copy link

Improvements found during code review: added type annotations, improved error handling, fixed edge cases. All existing tests pass.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Mar 18, 2026
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.11%. Comparing base (438cb40) to head (fb31388).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12254   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         130      130           
  Lines       45432    45455   +23     
  Branches     2400     2400           
=======================================
+ Hits        45028    45051   +23     
  Misses        273      273           
  Partials      131      131           
Flag Coverage Δ
CI-GHA 98.96% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.71% <100.00%> (+<0.01%) ⬆️
OS-Windows 96.98% <100.00%> (-0.01%) ⬇️
OS-macOS 97.86% <100.00%> (-0.01%) ⬇️
Py-3.10.11 97.41% <100.00%> (-0.01%) ⬇️
Py-3.10.20 97.89% <100.00%> (+<0.01%) ⬆️
Py-3.11.15 98.09% <100.00%> (-0.01%) ⬇️
Py-3.11.9 97.62% <100.00%> (+<0.01%) ⬆️
Py-3.12.10 97.71% <100.00%> (+<0.01%) ⬆️
Py-3.12.13 98.18% <100.00%> (-0.01%) ⬇️
Py-3.13.12 98.43% <100.00%> (-0.01%) ⬇️
Py-3.14.3 98.49% <100.00%> (-0.01%) ⬇️
Py-3.14.3t 97.48% <100.00%> (-0.01%) ⬇️
Py-pypy3.11.13-7.3.20 97.54% <100.00%> (+0.01%) ⬆️
VM-macos 97.86% <100.00%> (-0.01%) ⬇️
VM-ubuntu 98.71% <100.00%> (+<0.01%) ⬆️
VM-windows 96.98% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 59 untouched benchmarks


Comparing N3XT3R1337:fix/improve-code-quality (fb31388) with master (438cb40)

Open in CodSpeed

loop: asyncio.AbstractEventLoop,
) -> None:
"""Ensure the port is correctly extracted from getnameinfo for link-local IPv6."""
with patch("aiodns.DNSResolver") as mock:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
with patch("aiodns.DNSResolver") as mock:
with patch("aiodns.DNSResolver", autospec=True, spec_set=True) as mock:

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, it might make more sense to patch directly on the AsyncResolver instance?

) -> None:
"""Ensure the port is correctly extracted from getnameinfo for link-local IPv6."""
with patch("aiodns.DNSResolver") as mock:
mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(
Copy link
Member

Choose a reason for hiding this comment

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

Can probably skip this by patching the AsyncResolver instance below, but generally we don't want to add any calls to a mock, so something like this would be:

Suggested change
mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(
mock.return_value.getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result(

@Dreamsorcerer
Copy link
Member

added type annotations

I don't see this at all (should probably be a separate PR if it was there anyway).

I think these changes actually relate to aiodns 4. I'll let @bdraco review and figure out if they make sense.

@Dreamsorcerer Dreamsorcerer requested a review from bdraco March 18, 2026 13:43
themavik

This comment was marked as spam.

themavik

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants