Closed pinkavaj closed 5 years ago
NestedFunction
keep the source origin indention, so ast
could not parse. One quick way to fix is just removing any common leading whitespace from every line in source.
diff --git a/src/pydocstyle/checker.py b/src/pydocstyle/checker.py
index 29ff08f..03ab4d6 100644
--- a/src/pydocstyle/checker.py
+++ b/src/pydocstyle/checker.py
@@ -3,6 +3,7 @@
import ast
import string
import sys
+import textwrap
import tokenize as tk
from itertools import takewhile, chain
from re import compile as re
@@ -678,7 +679,7 @@ class ConventionChecker:
"""
if definition.kind == 'function':
- function_pos_args = get_function_args(definition.source)
+ function_pos_args = get_function_args(textwrap.dedent(definition.source))
docstring_args = set()
for line in context.following_lines:
match = ConventionChecker.GOOGLE_ARGS_REGEX.match(line)
If it seems good, I will pull request to resolve it.
Cannot this produce confusing outputs for users?
What is the progress with this issue?
Can a package/project owner approve and publish one of the PR's open for fixing the IndentationError? Until it's fixed my project can't feasibly upgrade to pydocstyle 4.0
This should be closed now - given that the issue is fixed in 4.0.1
Exception is raised for latest (6de6d93) pydocstyle when nested function contains docstring with arguments section.
How to reproduce:
Write python file
sample.py
:Run:
pydocstyle sample.py
Result: