@@ -50,11 +50,11 @@ def _get_statements(selection):
5050 for node in tree .body [1 :]:
5151 line_end = node .lineno - 1
5252 # 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,
5454 # 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.
5656 # 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 ) :
5858 # Using getattr instead of node.decorator_list or pyright will complain about an unknown member.
5959 line_end -= len (getattr (node , "decorator_list" ))
6060 ends .append (line_end )
@@ -71,7 +71,7 @@ def _get_statements(selection):
7171 start = node .lineno - 1
7272
7373 # 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 ) :
7575 # Using getattr instead of node.decorator_list or pyright will complain about an unknown member.
7676 start -= len (getattr (node , "decorator_list" ))
7777 block = "\n " .join (lines [start :end ])
0 commit comments