fix(python): Fixed nested return + yield call (#190)

This commit is contained in:
Colin Kennedy
2024-08-02 07:30:43 -07:00
committed by GitHub
parent ca214a4f6c
commit f9040ed838
3 changed files with 36 additions and 1 deletions

View File

@@ -272,6 +272,9 @@ return {
if nodes[i.Return] then if nodes[i.Return] then
validate_direct_returns(nodes, node) validate_direct_returns(nodes, node)
end
if nodes[i.Return] then
validate_bare_returns(nodes) validate_bare_returns(nodes)
end end

View File

@@ -309,7 +309,7 @@ end
--- with multiple annotation conventions. --- with multiple annotation conventions.
---@tag neogen-changelog ---@tag neogen-changelog
---@toc_entry Changes in neogen plugin ---@toc_entry Changes in neogen plugin
neogen.version = "2.19.1" neogen.version = "2.19.2"
--minidoc_afterlines_end --minidoc_afterlines_end
return neogen return neogen

View File

@@ -110,6 +110,38 @@ describe("python: google_docstrings", function()
assert.equal(expected, result) assert.equal(expected, result)
end) end)
it("works with methods + nested function + return", function()
local source = [[
def foo():|cursor|
def bar():|cursor|
return "blah"
yield "asdfsfd"
]]
local expected = [[
def foo():
"""[TODO:description]
Yields:
[TODO:description]
"""
def bar():
"""[TODO:description]
Returns:
[TODO:return]
"""
return "blah"
yield "asdfsfd"
]]
local result = make_google_docstrings(source)
assert.equal(expected, result)
end)
it("works with methods + nested functions", function() it("works with methods + nested functions", function()
local source = [[ local source = [[
# Reference: https://github.com/danymat/neogen/pull/151 # Reference: https://github.com/danymat/neogen/pull/151