Merge pull request #11143 from tushar-deepsource/patch-1
This commit is contained in:
commit
084d756ae6
1
AUTHORS
1
AUTHORS
|
@ -374,6 +374,7 @@ Tomer Keren
|
||||||
Tony Narlock
|
Tony Narlock
|
||||||
Tor Colvin
|
Tor Colvin
|
||||||
Trevor Bekolay
|
Trevor Bekolay
|
||||||
|
Tushar Sadhwani
|
||||||
Tyler Goodlet
|
Tyler Goodlet
|
||||||
Tzu-ping Chung
|
Tzu-ping Chung
|
||||||
Vasily Kuznetsov
|
Vasily Kuznetsov
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
- Prevent constants at the top of file from being detected as docstrings.
|
|
@ -676,6 +676,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||||
expect_docstring
|
expect_docstring
|
||||||
and isinstance(item, ast.Expr)
|
and isinstance(item, ast.Expr)
|
||||||
and isinstance(item.value, ast.Constant)
|
and isinstance(item.value, ast.Constant)
|
||||||
|
and isinstance(item.value.value, str)
|
||||||
):
|
):
|
||||||
doc = item.value.value
|
doc = item.value.value
|
||||||
if self.is_rewrite_disabled(doc):
|
if self.is_rewrite_disabled(doc):
|
||||||
|
|
|
@ -2042,3 +2042,17 @@ class TestReprSizeVerbosity:
|
||||||
self.create_test_file(pytester, DEFAULT_REPR_MAX_SIZE * 10)
|
self.create_test_file(pytester, DEFAULT_REPR_MAX_SIZE * 10)
|
||||||
result = pytester.runpytest("-vv")
|
result = pytester.runpytest("-vv")
|
||||||
result.stdout.no_fnmatch_line("*xxx...xxx*")
|
result.stdout.no_fnmatch_line("*xxx...xxx*")
|
||||||
|
|
||||||
|
|
||||||
|
class TestIssue11140:
|
||||||
|
def test_constant_not_picked_as_module_docstring(self, pytester: Pytester) -> None:
|
||||||
|
pytester.makepyfile(
|
||||||
|
"""\
|
||||||
|
0
|
||||||
|
|
||||||
|
def test_foo():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = pytester.runpytest()
|
||||||
|
assert result.ret == 0
|
||||||
|
|
Loading…
Reference in New Issue