Skip to content

Commit

Permalink
Fix line number assert corner case
Browse files Browse the repository at this point in the history
Closes #38 which provided the new test case.
  • Loading branch information
peterjc committed May 3, 2021
1 parent 3d4c899 commit 3eea955
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Version History
======= ========== ===========================================================
Version Released Changes
------- ---------- -----------------------------------------------------------
v0.2.3 2021-05-03 - Fixed line number assert in one-line docstring-only file.
v0.2.2 2021-04-30 - Fixed line number problem under Python 3.8 or later.
- Corrected off-by-one line number in module docstrings.
v0.2.1 2021-04-23 - Minor internal style change.
Expand Down
4 changes: 2 additions & 2 deletions flake8_rst_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import restructuredtext_lint as rst_lint


__version__ = "0.2.2"
__version__ = "0.2.3"


rst_prefix = "RST"
Expand Down Expand Up @@ -184,7 +184,7 @@ def run(self):
start = node.body[0].lineno - len(
ast.get_docstring(node, clean=False).splitlines()
)
if isinstance(node, ast.Module):
if isinstance(node, ast.Module) and start > 1:
start -= 1 # Why?
assert (
node.body[0].lineno >= 1 and start >= 0
Expand Down
1 change: 1 addition & 0 deletions tests/RST304/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""One line file, see :term:`preset` in the docs."""

0 comments on commit 3eea955

Please sign in to comment.