Skip to content

Commit

Permalink
fix(python): Fixed nested return + yield call (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinKennedy authored Aug 2, 2024
1 parent ca214a4 commit f9040ed
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lua/neogen/configurations/python.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ return {

if nodes[i.Return] then
validate_direct_returns(nodes, node)
end

if nodes[i.Return] then
validate_bare_returns(nodes)
end

Expand Down
2 changes: 1 addition & 1 deletion lua/neogen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ end
--- with multiple annotation conventions.
---@tag neogen-changelog
---@toc_entry Changes in neogen plugin
neogen.version = "2.19.1"
neogen.version = "2.19.2"
--minidoc_afterlines_end

return neogen
32 changes: 32 additions & 0 deletions tests/neogen/python_google_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,38 @@ describe("python: google_docstrings", function()
assert.equal(expected, result)
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()
local source = [[
# Reference: https://github.com/danymat/neogen/pull/151
Expand Down

0 comments on commit f9040ed

Please sign in to comment.