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

Ensure type is passed through _io.sync #384

Closed jacobtomlinson closed 5 months ago

jacobtomlinson commented 5 months ago

Use a generic class type to ensure type hints work correctly on classes decorated with @sync.

xref #381

Before

from kr8s.objects import Pod

# Type checker shows `pod` as `Any`
pod = Pod("kube-apiserver", namespace="kube-system")

# Assisting the type checker does not work, `pod` is still recognized as `Any`
pod: Pod = Pod("kube-apiserver", namespace="kube-system")

After

from kr8s.objects import Pod

# Type checker shows `pod` as `Pod` even without the assistance
pod = Pod("kube-apiserver", namespace="kube-system")

cc @marcodlk

codecov[bot] commented 5 months ago

Codecov Report

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

Project coverage is 95.22%. Comparing base (87063fc) to head (e8d75ad). Report is 100 commits behind head on main.

Files Patch % Lines
kr8s/_io.py 92.30% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #384 +/- ## ========================================== + Coverage 94.61% 95.22% +0.60% ========================================== Files 29 29 Lines 3141 3416 +275 ========================================== + Hits 2972 3253 +281 + Misses 169 163 -6 ```

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