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

Fix false-positive D405 recognition #317

Merged
merged 8 commits into from Jun 11, 2018
Merged

Fix false-positive D405 recognition #317

merged 8 commits into from Jun 11, 2018

Conversation

@shacharoo
Copy link
Member

shacharoo commented Jun 6, 2018

Solves #311.

The problem was that the regex split words when reached an underscore, so "arguments_bla" was caught as "arguments".

@shacharoo shacharoo changed the title Fix d405 Fix false-positive D405 recognition Jun 6, 2018
@shacharoo shacharoo requested a review from Nurdok Jun 6, 2018
shacharoo added 2 commits Jun 6, 2018
@shacharoo shacharoo added this to To do in Pydocstyle 2.2.0 via automation Jun 6, 2018
@shacharoo shacharoo moved this from To do to In progress in Pydocstyle 2.2.0 Jun 6, 2018
@shacharoo shacharoo self-assigned this Jun 6, 2018
@@ -17,6 +17,11 @@ New features
line of the ``def``/``class`` it corresponds to (#238, #83).
* Updated description of pep257 and numpy conventions (#300).

Bug Fixes

* Fixed a false-positive recognition of section names causing D405 to be thrown

This comment has been minimized.

Copy link
@Nurdok

Nurdok Jun 7, 2018

Member

thrown -> reported?

section_name_suffix = context.line.lstrip(context.section_name).strip()
section_name_suffix = context.line.strip().lstrip(
context.section_name.strip()
).strip()

This comment has been minimized.

Copy link
@Nurdok

Nurdok Jun 7, 2018

Member

Weird formatting, can you make it look better?

return (is_blank(section_name_suffix) or
prev_line_ends_with_punctuation or
is_blank(context.previous_line))
return ((is_blank(section_name_suffix) or

This comment has been minimized.

Copy link
@Nurdok

Nurdok Jun 7, 2018

Member

If we're going verbose 😄:

this_line_looks_like_a_section_name = is_blank(section_name_suffix) or prev_line_ends_with_punctuation
prev_line_looks_like_end_of_paragraph = prev_line_ends_with_punctuation or is_blank(context.previous_line)
return this_line_looks_like_a_section_name and prev_line_looks_like_end_of_paragraph

This comment has been minimized.

Copy link
@shacharoo

shacharoo Jun 8, 2018

Author Member

I don't know if you're sarcastic, but I actually think it's better!

Parameters
----------
attributes_are_fun: attributes for the function.

This comment has been minimized.

Copy link
@Nurdok

Nurdok Jun 7, 2018

Member

Perhaps also add a case where the parameter name is exactly a section header name (e.g., attributes)?

This comment has been minimized.

Copy link
@shacharoo

shacharoo Jun 8, 2018

Author Member

Look at the test below it - it's exactly that.

@Nurdok
Nurdok approved these changes Jun 11, 2018
@Nurdok Nurdok merged commit 676e4f3 into PyCQA:master Jun 11, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Pydocstyle 2.2.0 automation moved this from In progress to Done Jun 11, 2018
@shacharoo shacharoo deleted the shacharoo:fix-D405 branch Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.