zincware / ZnTrack

Create, visualize, run & benchmark DVC pipelines in Python & Jupyter notebooks.
https://zntrack.readthedocs.io
Apache License 2.0
44 stars 4 forks source link

add typing support for fields #767

Open NiklasKappel opened 5 months ago

NiklasKappel commented 5 months ago

Node constructors already work with the addition of 'dataclass_transform' in ZnInit.

For the field specifier functions we could lie about the return type. If they don't take arguments (e.g. outs) that's easy, because we just annotate a return type of Any. Otherwise, they seem to forward all arguments to the __init__ of ZnInit's Descriptor, so we could use the exact same type hints as for the desc factory function.

This way we would need boilerplate type stubs for all functions in fields.py. I don't know if it is possible to add type hints for the constructor (__init__ or __new__??) of Descriptor directly and propagate that through the inheritance chain.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.82%. Comparing base (6698c4a) to head (637ae0d). Report is 4 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #767 +/- ## ========================================== - Coverage 91.01% 86.82% -4.19% ========================================== Files 25 25 Lines 2047 2057 +10 Branches 974 979 +5 ========================================== - Hits 1863 1786 -77 - Misses 184 271 +87 ``` | [Flag](https://app.codecov.io/gh/zincware/ZnTrack/pull/767/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zincware) | Coverage Δ | | |---|---|---| | [fulltest](https://app.codecov.io/gh/zincware/ZnTrack/pull/767/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zincware) | `86.82% <ø> (+0.06%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zincware#carryforward-flags-in-the-pull-request-comment) to find out more.

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