docs: add docstrings or explicit overrides to dump and as_write methods - #2793
docs: add docstrings or explicit overrides to dump and as_write methods#2793MortGron wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request systematically adds the @override decorator to overridden methods (primarily dump and as_write) across various CogniteResource subclasses to improve type safety and consistency. Feedback suggests applying the @override decorator to TransformationBlockedInfo.dump in cognite/client/data_classes/transformations/common.py for consistency with the rest of the changes.
| def dump(self, camel_case: bool = True) -> dict[str, Any]: | ||
| """Dump the instance into a json serializable Python data type.""" | ||
| return basic_obj_dump(self, camel_case) |
There was a problem hiding this comment.
For consistency with other CogniteResource subclasses in this file and across the codebase, TransformationBlockedInfo.dump should use the @override decorator instead of a duplicate docstring.
| def dump(self, camel_case: bool = True) -> dict[str, Any]: | |
| """Dump the instance into a json serializable Python data type.""" | |
| return basic_obj_dump(self, camel_case) | |
| @override | |
| def dump(self, camel_case: bool = True) -> dict[str, Any]: | |
| return basic_obj_dump(self, camel_case) |
References
- Consistency: Follow established patterns across the codebase (link)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2793 +/- ##
==========================================
+ Coverage 93.07% 93.11% +0.04%
==========================================
Files 516 516
Lines 53263 53687 +424
==========================================
+ Hits 49572 49990 +418
- Misses 3691 3697 +6
🚀 New features to boost your workflow:
|
Description
Many public methods do not have docstrings. It is possible to automate the check for missing docstrings using https://docs.astral.sh/ruff/rules/undocumented-public-method/.
This requires all public methods either to have a docstring, or to have a decorater indicating why they should not. The most common scenario is that a method inherits the docstring from some parent class. However, that this is the intention must be made clear by using the
@overridedecorater introduced in Python 3.12 (and available intyping_extensions).Because enabling this automated check will require a vast number of code line changes, it has been split up into multiple PRs. In this PR almost all
dumpandas_writemethods have either got theoverridedecorator or have got a docstring.Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.