Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Report docstring content violations on docstring line (fixes #83) #238

Merged
merged 4 commits into from
Dec 18, 2017

Conversation

lordmauve
Copy link
Contributor

Add .start and .end attributes to docstring objects that hold the starting and ending line numbers of the docstring token. Docstring was changed to a subclass of str to allow this, ensuring backwards compatibility.

Add a property .error_lineno to Definition. This will use the docstring's line number if it exists, or the definition's line number otherwise.

Finally, switch Error to use the new .error_lineno property.

Tested on Python 2.7, 3.3-3.5 and PyPy with Tox.

the start and end of the token.

"""
def __new__(cls, v, start, end):
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? Why not just call super in __init__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC, you can't subclass various native types without defining new().

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 confirmed, this is needed.

@lordmauve
Copy link
Contributor Author

Bump. Is merging this blocked by #240?

@lordmauve
Copy link
Contributor Author

Disappointed this didn't make 2.0.0. Please let me know what needs to happen for this to be merged.

@Nurdok
Copy link
Member

Nurdok commented Apr 25, 2017

@lordmauve sorry about that. I think this will go in the next minor version.

@lordmauve
Copy link
Contributor Author

I just rebased. @Nurdok, can this be merged?

@Nurdok
Copy link
Member

Nurdok commented Dec 18, 2017

Hi @lordmauve, can you please just add a line to the release notes first?

@lordmauve
Copy link
Contributor Author

I've added to the notes under a new minor version number. The release date will need to be added when you come to release this.

@@ -4,6 +4,14 @@ Release Notes
**pydocstyle** version numbers follow the
`Semantic Versioning <http://semver.org/>`_ specification.

2.2.0 - not yet released
Copy link
Member

Choose a reason for hiding this comment

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

Just put "Current Development Version" in the title instead of specifying the actual version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

New features

* Violations are now reported on the line where the docstring starts, not the
line of the ``def``/``class`` it corresponds to.
Copy link
Member

Choose a reason for hiding this comment

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

Link to both this (#238) and #83.

Sorry for the nitpicking, in a few moments this will be merged :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Nurdok Nurdok merged commit ac20e2c into PyCQA:master Dec 18, 2017
@Nurdok
Copy link
Member

Nurdok commented Dec 18, 2017

Merged. @lordmauve, thank you so much for your patience, and for putting in the time to do this!

@lordmauve lordmauve deleted the docstring-linenos branch December 18, 2017 14:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants