Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8785da9

Browse files
committed
Clear decorators if we skip a function
1 parent 78f711f commit 8785da9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

mypy/stubgen.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,10 @@ def visit_mypy_file(self, o: MypyFile) -> None:
538538
self.add('# %s\n' % name)
539539

540540
def visit_func_def(self, o: FuncDef, is_abstract: bool = False) -> None:
541-
if self.is_private_name(o.name(), o.fullname()):
542-
return
543-
if self.is_not_in_all(o.name()):
544-
return
545-
if self.is_recorded_name(o.name()):
541+
if (self.is_private_name(o.name(), o.fullname())
542+
or self.is_not_in_all(o.name())
543+
or self.is_recorded_name(o.name())):
544+
self.clear_decorators()
546545
return
547546
if not self._indent and self._state not in (EMPTY, FUNC) and not o.is_awaitable_coroutine:
548547
self.add('\n')

test-data/unit/stubgen.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,24 @@ class F:
12621262
@t.coroutine
12631263
def g(): ...
12641264

1265+
[case testCoroutineSpecialCase_import]
1266+
import asyncio
1267+
1268+
__all__ = ['C']
1269+
1270+
@asyncio.coroutine
1271+
def f():
1272+
pass
1273+
1274+
class C:
1275+
def f(self):
1276+
pass
1277+
[out]
1278+
import asyncio
1279+
1280+
class C:
1281+
def f(self) -> None: ...
1282+
12651283
-- Tests for stub generation from semantically analyzed trees.
12661284
-- These tests are much slower, so use the `_semanal` suffix only when needed.
12671285

0 commit comments

Comments
 (0)