fix: improve type safety and error handling#12254
fix: improve type safety and error handling#12254N3XT3R1337 wants to merge 1 commit intoaio-libs:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| loop: asyncio.AbstractEventLoop, | ||
| ) -> None: | ||
| """Ensure the port is correctly extracted from getnameinfo for link-local IPv6.""" | ||
| with patch("aiodns.DNSResolver") as mock: |
There was a problem hiding this comment.
| with patch("aiodns.DNSResolver") as mock: | |
| with patch("aiodns.DNSResolver", autospec=True, spec_set=True) as mock: |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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:
| mock().getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result( | |
| mock.return_value.getaddrinfo.return_value = fake_aiodns_getaddrinfo_ipv6_result( |
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. |
Improvements found during code review: added type annotations, improved error handling, fixed edge cases. All existing tests pass.