@@ -50,11 +50,11 @@ def _get_statements(selection): |
50 | 50 | for node in tree.body[1:]: |
51 | 51 | line_end = node.lineno - 1 |
52 | 52 | # Special handling of decorators: |
53 | | - # In Python 3, decorators are not taken into account in the value returned by lineno, |
| 53 | + # In Python 3.8 and higher, decorators are not taken into account in the value returned by lineno, |
54 | 54 | # and we have to use the length of the decorator_list array to compute the actual start line. |
55 | | - # In Python 2.7, lineno takes into account decorators, so this offset check is unnecessary. |
| 55 | + # Before that, lineno takes into account decorators, so this offset check is unnecessary. |
56 | 56 | # Also, not all AST objects can have decorators. |
57 | | - if hasattr(node, "decorator_list") and sys.version_info.major >= 3: |
| 57 | + if hasattr(node, "decorator_list") and sys.version_info >= (3, 8): |
58 | 58 | # Using getattr instead of node.decorator_list or pyright will complain about an unknown member. |
59 | 59 | line_end -= len(getattr(node, "decorator_list")) |
60 | 60 | ends.append(line_end) |
@@ -71,7 +71,7 @@ def _get_statements(selection): |
71 | 71 | start = node.lineno - 1 |
72 | 72 |
|
73 | 73 | # Special handling of decorators similar to what's above. |
74 | | - if hasattr(node, "decorator_list") and sys.version_info.major >= 3: |
| 74 | + if hasattr(node, "decorator_list") and sys.version_info >= (3, 8): |
75 | 75 | # Using getattr instead of node.decorator_list or pyright will complain about an unknown member. |
76 | 76 | start -= len(getattr(node, "decorator_list")) |
77 | 77 | block = "\n".join(lines[start:end]) |
|