From f9040ed838b85c181b53e2c236049fc7e007290b Mon Sep 17 00:00:00 2001 From: Colin Kennedy Date: Fri, 2 Aug 2024 07:30:43 -0700 Subject: [PATCH] fix(python): Fixed nested return + yield call (#190) --- lua/neogen/configurations/python.lua | 3 +++ lua/neogen/init.lua | 2 +- tests/neogen/python_google_spec.lua | 32 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lua/neogen/configurations/python.lua b/lua/neogen/configurations/python.lua index c56adb0..02d2c4b 100644 --- a/lua/neogen/configurations/python.lua +++ b/lua/neogen/configurations/python.lua @@ -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 diff --git a/lua/neogen/init.lua b/lua/neogen/init.lua index 707837b..2c67cbf 100644 --- a/lua/neogen/init.lua +++ b/lua/neogen/init.lua @@ -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 diff --git a/tests/neogen/python_google_spec.lua b/tests/neogen/python_google_spec.lua index b7544a4..f69ec02 100644 --- a/tests/neogen/python_google_spec.lua +++ b/tests/neogen/python_google_spec.lua @@ -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