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

Docstr comment #3787

Merged
merged 3 commits into from
Sep 23, 2020
Merged

Docstr comment #3787

merged 3 commits into from
Sep 23, 2020

Conversation

gschaffner
Copy link
Contributor

Steps

  • 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.

Description

Fix spell-checker crash on indented docstring lines that look like # comments. See #3786 for more info.

Type of Changes

Type
🐛 Bug fix

Related Issue

Closes #3786

@gschaffner
Copy link
Contributor Author

Should a new test be added for this as well?

@coveralls
Copy link

coveralls commented Aug 23, 2020

Coverage Status

Coverage remained the same at 90.721% when pulling 8e7e8f7 on gschaffner:docstr_comment into 5728d82 on PyCQA:master.

@Pierre-Sassoulas
Copy link
Member

Hello, thank you for the PR. The examples you gave in #3786 seems good candidates for a functional test, you can add them in tests/functional/. Also, I don't know what kind of work would be involved or if I understood what was done correctly, but would it be possible to fix the "docstring" msgid treatment instead of skipping it?

@gschaffner
Copy link
Contributor Author

Hi, thanks for the reply! I do not understand tests/functional very well, and I cannot seem to find any functional tests of the spell checker. Would https://github.com/PyCQA/pylint/blob/3e7e3ca443b9355cbc13467d9c3b8fa794647410/tests/checkers/unittest_spelling.py be a better place to add such tests? Something like https://github.com/PyCQA/pylint/blob/3e7e3ca443b9355cbc13467d9c3b8fa794647410/tests/checkers/unittest_spelling.py#L175-L191

Also, I may be misunderstanding you but I don't think that my change skips any treatment. A line of a docstring that looks like a comment should not have its leading # trimmed off as if it was a comment. To the interpreter, such a line isn't a comment—it's part of a string.

@Pierre-Sassoulas
Copy link
Member

No problem ! Yes adding unit test would be a plus too :)

For functional tests, you can add your example like what was done in this merge request in tests/functional/l/line_too_long.py and tests/functional/l/line_too_long.txt . You can create both files with the name you want or use another pre-existing file, it have to be inside "tests/functional/" and have a .py and a .txt with the same basename.

@gschaffner
Copy link
Contributor Author

It seems to me that this needs to be covered by unit tests rather than functional tests. I believe there aren't currently any functional tests of the spell checker because (AFAIK)

  • There is not a way to set --spelling-dict en_US for functional tests. Pylint won't report spelling issues if spelling-dict is not set.
  • There is not a way to handle multiline pylint errors (like wrong-spelling-in-docstring) in tests/functional/f/foo.txt.

@Pierre-Sassoulas
Copy link
Member

Ho, ok, I did not use spell checking much. It makes sense to just use unit test then.

@Pierre-Sassoulas Pierre-Sassoulas self-assigned this Sep 6, 2020
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.

This seems ready for merging, thank you. @gschaffner, could you rebase on the latest master to fix the conflicts, please ?

@gschaffner
Copy link
Contributor Author

gschaffner commented Sep 22, 2020

Done! @Pierre-Sassoulas

Edit: Don't merge yet, I realized that we should use visit_functiondef instead of visit_classdef. One second. Done.

@Pierre-Sassoulas Pierre-Sassoulas merged commit 5d620c2 into pylint-dev:master Sep 23, 2020
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.

Spell-checker crashes if a regex('^ +#') line in a docstring contains a typo
3 participants