kr8s-org / kr8s

A batteries-included Python client library for Kubernetes that feels familiar for folks who already know how to use kubectl
https://kr8s.org
BSD 3-Clause "New" or "Revised" License
839 stars 45 forks source link

Improve type annotation for APIObject constructor #453

Closed jacobtomlinson closed 3 months ago

jacobtomlinson commented 3 months ago

The resource argument in all APIObject based classes is annotated to take a dict, but it's far more flexible than that.

This PR fixes the type annotation by replacing it with one that accurately reflects what it supports.

I also replaced a contextlib.suppress(...) with an isinstance and Protocol which seems much more pleasant.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.02%. Comparing base (87063fc) to head (7625901). Report is 125 commits behind head on main.

Files with missing lines Patch % Lines
kr8s/_objects.py 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #453 +/- ## ========================================== + Coverage 94.61% 95.02% +0.40% ========================================== Files 29 30 +1 Lines 3141 3882 +741 ========================================== + Hits 2972 3689 +717 - Misses 169 193 +24 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.