Skip to content
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

Properly identify undocumented parameters and add new message called missing-any-param-doc #5097

Merged
merged 14 commits into from
Oct 10, 2021

Conversation

ksaketou
Copy link
Contributor

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature, or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Type of Changes

Type
🐛 Bug fix
✨ New feature

Description

This PR fixes the problem where undocumented parameters where not being spotted correctly
by missing-param-doc and missing-type-doc. Also, a new message has been added called
missing-any-param-doc which is triggered when a function has neither parameter nor parameter
type documentation.

Related issue

Closes #3799

This commit fixes the problem where non documented parameters where not being identified properly.
Also, it adds a new message called missing-any-param-doc for when a function has no parameter and type doc at all.
This commit adds new test cases for the missing-param-doc and missing-type-doc messages.
Also, it contains tests for the new message missing-any-param-doc.
This commit adds the new message where needed in other files instead of triggering both
missing-param-doc and missing-type-doc.
@coveralls
Copy link

coveralls commented Sep 30, 2021

Pull Request Test Coverage Report for Build 1325392201

  • 14 of 14 (100.0%) changed or added relevant lines in 2 files are covered.
  • 38 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.004%) to 93.209%

Files with Coverage Reduction New Missed Lines %
pylint/message/message_handler_mix_in.py 5 93.59%
pylint/lint/pylinter.py 33 93.51%
Totals Coverage Status
Change from base Build 1325265172: 0.004%
Covered Lines: 13560
Relevant Lines: 14548

💛 - Coveralls

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

I don't have enough time for a full review, just a small remark about documentation :)

'Missing any documentation in "%s"',
"missing-any-param-doc",
"Please add parameter and/or type documentation.",
),
Copy link
Member

Choose a reason for hiding this comment

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

We could add an old names here, the ideal would be to not force to disable missing-any-param when the old one was already disabled. But they are not really equivalent so maybe you were right to not add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what does the old names contain exactly?

Copy link
Member

Choose a reason for hiding this comment

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

You can search for C0111 (the old name for missing-function-docstring) for an example :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you say that instead of adding an old names, we can add a warning in the 2.12 what's new file?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, something like "A warning might appear if you disabled missing-param-docand missing-type-doc because it became missing-any-param-doc when there isn't any doc."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added my changes in the what's new for 2.11 and under 2.11.2 in ChangeLog, should I move them to 2.12 then?

Copy link
Member

Choose a reason for hiding this comment

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

Yes sorry I did not catch that, this is a "new feature" :)

tests/functional/ext/docparams.py Show resolved Hide resolved
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.12.0 milestone Oct 5, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Blocked 🚧 Blocked by a particular issue labels Oct 5, 2021
@cdce8p cdce8p modified the milestones: 2.13.0, 2.12.0 Oct 5, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Hacktoberfest and removed Blocked 🚧 Blocked by a particular issue labels Oct 10, 2021
ChangeLog Show resolved Hide resolved
ChangeLog Outdated Show resolved Hide resolved
Comment on lines -729 to +737
\n # description starts on a new line
\s* (.*) # description
\s* (.*) # optional description
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why there's a change here, I don't get it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the '\n', the cases where there was only type documentation could not be identified (in cases with only type doc, there is no new line). This is probably why the message worked only if one param was documented correctly.

Copy link
Member

Choose a reason for hiding this comment

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

Ho, so this is in fact a very technical regex bug fix ! "Fixed a 10+ year old regex bug by removing 2 characters" should be a badge you can pin on your github profile 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hahaha that's true I guess

missing_type_doc = (expected_argument_names - params_with_type) - (
not_needed_type_in_docstring | expected_but_ignored_argument_names
)
if (
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Thank you @ksaketou very nice change. I have a small question bout a change that I don't understand but this will definitely be in 2.12 :)

@ksaketou
Copy link
Contributor Author

Thank you!:)

@Pierre-Sassoulas Pierre-Sassoulas merged commit f2b0c48 into pylint-dev:main Oct 10, 2021
@ksaketou ksaketou deleted the parameter_doc branch October 15, 2021 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parameter Documentation checker only works if at least one parameter is documented properly
4 participants