Skip to content

MNT Add ignore_types to assert_docstring_consistency #30944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 28, 2025

Conversation

lucyleeow
Copy link
Member

Reference Issues/PRs

Follows from #28678 (comment)
Alternative to #30943

What does this implement/fix? Explain your changes.

ignore_types takes a list of param/attr/returns to exclude from matching types.
Much simpler usage and implementation vs #30943 but no matching is done at all.

Any other comments?

Draft as just to show what this option would look like.

cc @glemaitre @adrinjalali @StefanieSenger

Copy link

github-actions bot commented Mar 5, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 284544f. Link to the linter CI: here

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

Comment on lines 801 to 802
List of parameter/attribute/return names to exclude from matching type
between objects.
Copy link
Member

Choose a reason for hiding this comment

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

Is this what it does? I think it would be helpful to have the example in the docstring here to be clear

Suggested change
List of parameter/attribute/return names to exclude from matching type
between objects.
List of parameter/attribute/return names to exclude from matching type
between objects. For instance, the following two would be accepted:
.. code
param : str, None
param description
param : str
param description

Copy link
Member Author

@lucyleeow lucyleeow Mar 7, 2025

Choose a reason for hiding this comment

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

Yes that's exactly what it would do.

Do you prefer this PR to #30943 ? It is much simpler and I think I would prefer it for this reason.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I just close the other PR then...or wait for more opinions? I am happy to close.

@glemaitre
Copy link
Member

I'm fine with the proposal here.

@lucyleeow
Copy link
Member Author

I think this is preferred over #30943 so I will close that PR

@lucyleeow
Copy link
Member Author

@glemaitre @adrinjalali I think you two are the only ones following this, do we think this should go in?

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

This is good to go I think.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Minor nits

@@ -688,7 +688,12 @@ def _get_diff_msg(docstrings_grouped):


def _check_consistency_items(
items_docs, type_or_desc, section, n_objects, descr_regex_pattern=""
items_docs,
type_or_desc,
Copy link
Member

Choose a reason for hiding this comment

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

Can we document that the possible values for type_or_desc is "type specification" and "description"?

Copy link
Member Author

@lucyleeow lucyleeow Apr 28, 2025

Choose a reason for hiding this comment

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

Thanks this function was definitely worth a parameter docstring section.

@thomasjpfan thomasjpfan merged commit 53a7f4f into scikit-learn:main Apr 28, 2025
36 checks passed
@lucyleeow lucyleeow deleted the ds_type_ignore branch April 28, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants