From da39081d5aed61a16874fcf37157183752e1eac5 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 6 Jul 2017 01:14:35 +0200 Subject: [PATCH] Fix another small decorator issues. --- parso/python/normalizer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 2bc6172..34e5f4c 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -299,8 +299,14 @@ class PEP8Normalizer(Normalizer): ) and actual_leaf.parent.parent.type != 'decorated' ) if needs_lines and actual < wanted: - # The first leaf should not be added. - if self._actual_previous_leaf is not None: + func_or_cls = actual_leaf.parent + suite = func_or_cls.parent + if suite.type == 'decorated': + suite = suite.parent + + # The first leaf of a file or a suite should not need blank + # lines. + if suite.children[int(suite.type == 'suite')] != func_or_cls: code = 302 if wanted == 2 else 301 message = "expected %s blank line, found %s" \ % (wanted, actual)