Skip to content

docs: Remove duplicate type hints in docstrings and annotations#2483

Open
MortGron wants to merge 7 commits intopysdk-release-v8from
remove-duplicate-type-hints
Open

docs: Remove duplicate type hints in docstrings and annotations#2483
MortGron wants to merge 7 commits intopysdk-release-v8from
remove-duplicate-type-hints

Conversation

@MortGron
Copy link
Copy Markdown
Contributor

Description

The duplication of type hints in both docstring and as annotations makes the docstrings unnecessarily hard to read as a developer. It is possible to remove type hints in the docstrings without changing the structure of the documentation. This PR removes all type hints from the docstrings, but enables a Sphinx extension to keep the type hints in the documentation.

Current documentation:

image

New documentation:

image

A few points to discuss:

  • Should it still be allowed to provide type hints in the docstrings? It might make sense for very long type hints to have a custom type hint instead
  • Is the change in documentation look accepptable? All type hints are now stylized as inline code in the documentation, which in my opinion is slightly less readable than how it was.

Checklist:

  • Tests added/updated.
  • Documentation updated. Documentation is generated from docstrings - these must be updated according to your change.
    If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.
  • The PR title follows the Conventional Commit spec.

Copy link
Copy Markdown
Contributor

@erlendvollset erlendvollset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most (sane) modern tooling relies on signature annotations, so this is a good change.

@haakonvt does this affect the v8 sync app generator?

@haakonvt
Copy link
Copy Markdown
Contributor

haakonvt commented Mar 2, 2026

I think most (sane) modern tooling relies on signature annotations, so this is a good change.

@haakonvt does this affect the v8 sync api generator?

I think it should still work!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.41%. Comparing base (ffcc432) to head (d1ce6cb).
⚠️ Report is 5 commits behind head on pysdk-release-v8.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           pysdk-release-v8    #2483      +/-   ##
====================================================
- Coverage             93.41%   93.41%   -0.01%     
====================================================
  Files                   478      478              
  Lines                 48217    48230      +13     
====================================================
+ Hits                  45044    45054      +10     
- Misses                 3173     3176       +3     
Files with missing lines Coverage Δ
cognite/client/_api/agents/agents.py 100.00% <ø> (ø)
cognite/client/_api/ai/tools/documents.py 78.57% <ø> (ø)
cognite/client/_api/annotations.py 95.65% <ø> (ø)
cognite/client/_api/assets.py 97.35% <ø> (ø)
cognite/client/_api/data_modeling/containers.py 98.14% <ø> (ø)
cognite/client/_api/data_modeling/data_models.py 100.00% <ø> (ø)
cognite/client/_api/data_modeling/graphql.py 100.00% <ø> (ø)
cognite/client/_api/data_modeling/instances.py 87.71% <ø> (-0.85%) ⬇️
...nite/client/_api/data_modeling/space_statistics.py 100.00% <ø> (ø)
cognite/client/_api/data_modeling/spaces.py 100.00% <ø> (ø)
... and 214 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MortGron
Copy link
Copy Markdown
Contributor Author

MortGron commented Mar 29, 2026

image

These annotations with internal classes causes problems. They should be dealt with in a separate PR.

@MortGron MortGron marked this pull request as ready for review March 29, 2026 18:39
@MortGron MortGron requested review from a team as code owners March 29, 2026 18:39
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to declutter the codebase by removing redundant type hints from docstrings. By relying on Python type annotations instead, the documentation becomes cleaner and easier to maintain. A Sphinx extension is enabled to ensure that type information remains present in the generated documentation, maintaining the same level of detail for end-users.

Highlights

  • Documentation Cleanup: Removed redundant type hints from docstrings across the codebase to improve readability, as these are already captured in type annotations.
  • Tooling Update: Updated .pre-commit-config.yaml to disable type hint checking in docstrings, ensuring consistency with the new documentation style.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .gemini/** (1)
    • .gemini/styleguide.md
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/build.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs a large-scale cleanup of docstrings across the SDK by removing redundant type information from the 'Args' and 'Returns' sections. This change shifts the source of truth for type information to the Python type hints in the function signatures, improving maintainability. Additionally, the pre-commit configuration for darglint has been updated to disable checks for these docstring type hints. I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants