Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #218 +/- ##
==========================================
+ Coverage 97.69% 98.36% +0.66%
==========================================
Files 3 5 +2
Lines 564 1345 +781
Branches 38 70 +32
==========================================
+ Hits 551 1323 +772
- Misses 7 16 +9
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
That means people need to update their code twice if they want to use the new API. I find that more incovenient than the alternative.
It's a simple mapping, I don't think it would be a big deal. Having to change the code twice to use the new stuff sounds worse IMHO. |
|
Fair point on the double migration. Though with But I see the appeal of type-specific methods being a cleaner one-time migration. I'm okay either way. What do you think is the better path forward? |
|
Let's sleep on it :-) Maybe others want to weigh in too? |
I would have to agree that would be a bit awkward, I'd probably want to avoid that. It's also very easy to lose type safety if you're trying to access these functions dynamically like that. Convenience methods in addition to the general query function (like in aiohttp) would be fine though. It doesn't sound like there's a perfect solution available, but I'd be inclined to go with bdraco's proposal currently, unless any better ideas appear. One other idea I can think of (I'm not really for or against it though) is tweaking the function signature in some way. For example, if the new version used an enum instead of strings, then we can use the same function and just switch the implementation depending on whether the argument is str or enum (which could be cleanly implemented with functools.singledispatchmethod decorator). |
|
Also, it looks like the new version has lost the overloads we had for each query type. It looks like we'll need to rework the typing in pycares 5 to make that work again. |
|
pycares should probably have similar overloads for the callback here: That way it can verify the callback expects to receive the specific type it will return, like: |
|
Happy new year everyone! My thoughts on the matter. Since people are going to need to migrate eventually, IMHO the best path forward is a new major version with breaking changes, which depends on pycares >=5,<6. People that want to wait can pin to aiodns 3. |
|
The challenge for us is that Home Assistant has 18+ libraries that depend on aiodns. A clean break means all of them have to update simultaneously before we can upgrade, and we can't get pycares 5.x until that happens (blocking any security fixes, performance improvements, etc). Realistically that takes 6-12 months of coordination, and some libraries inevitably get abandoned along the way and need replacing. With backward compat we can upgrade aiodns/pycares immediately and let libraries migrate at their own pace over time. No blocking dependency chain. If the preference is a clean break, we'd likely need to fork or find an alternative solution for Home Assistant, which isn't ideal for either project. |
|
I see. Fair enough. Let's go with your proposal then. |
|
Thank you |
|
Now I need to retest everywhere in HA |
|
didn't find anything else. tested everything I could think of. |
What do these changes do?
Add support for pycares 5.0 while maintaining full backward compatibility with existing code.
Key changes:
aiodns/compat.pymodule with frozen dataclasses matching pycares 4.x field namesquery_dns()method returning native pycares 5.xDNSResult(with access to answer/authority/additional sections)query()method deprecated (emitsDeprecationWarning) but continues to work with pycares 4.x compatible resultsgethostbyname()now usesgetaddrinfo()internally (pycares 5 removed gethostbyname)nameserversproperty strips port suffix added by pycares 5.x for backward compatibilityAresQueryAResult,AresQueryAAAAResult,AresQueryCNAMEResult,AresQueryMXResult,AresQueryNSResult,AresQueryTXTResult,AresQuerySOAResult,AresQuerySRVResult,AresQueryNAPTRResult,AresQueryCAAResult,AresQueryPTRResult,AresHostResultMigration path
Future migration to aiodns 5.x
The temporary
query_dns()naming allows gradual migration without breaking changes:query()query_dns()query()for back compatIn aiodns 5.x,
query()will become the primary API returning native pycares 5.x types, andquery_dns()will remain as an alias for backward compatibility. This allows downstream projects to migrate at their own pace.Field mappings (pycares 5.x → aiodns compat)
data.addrhostdata.exchangehostdata.nsdnamehostdata.datatextmname/rname/expire/minimumnsname/hostmaster/expires/minttldata.targethostdata.tagpropertydata.dnamenameAre there changes in behavior for the user?
Backward compatible - existing code continues to work unchanged (with deprecation warning on
query()).Version bumped to 4.0.0 due to:
query()are now aiodns dataclasses instead of pycares typesThe
query()type change is unlikely to affect anyone since checkingisinstance(result, pycares.ares_query_*_result)was uncommon. Field access patterns remain identical to pycares 4.x.Users can migrate to
query_dns()at their own pace while staying on aiodns 4.x, avoiding coordinated dependency upgrades.Related issue number
Fixes #214
Checklist