19
19
import pytest
20
20
21
21
from astroid import Instance , builder , nodes , test_utils , util
22
- from astroid .const import IS_PYPY , PY38 , PY38_PLUS , PY39_PLUS
22
+ from astroid .const import IS_PYPY , PY38 , PY38_PLUS , PY39_PLUS , PYPY_7_3_11_PLUS
23
23
from astroid .exceptions import (
24
24
AstroidBuildingError ,
25
25
AstroidSyntaxError ,
@@ -130,18 +130,18 @@ def function(
130
130
def test_decorated_class_lineno () -> None :
131
131
code = textwrap .dedent (
132
132
"""
133
- class A:
133
+ class A: # L2
134
134
...
135
135
136
136
@decorator
137
- class B:
137
+ class B: # L6
138
138
...
139
139
140
140
@deco1
141
141
@deco2(
142
142
var=42
143
143
)
144
- class C:
144
+ class C: # L13
145
145
...
146
146
"""
147
147
)
@@ -155,23 +155,15 @@ class C:
155
155
156
156
b = ast_module .body [1 ]
157
157
assert isinstance (b , nodes .ClassDef )
158
- if PY38 and IS_PYPY :
159
- # Not perfect, but best we can do for PyPy 3.8
160
- assert b .fromlineno == 7
161
- else :
162
- assert b .fromlineno == 6
158
+ assert b .fromlineno == 6
163
159
assert b .tolineno == 7
164
160
165
161
c = ast_module .body [2 ]
166
162
assert isinstance (c , nodes .ClassDef )
167
- if not PY38_PLUS :
168
- # Not perfect, but best we can do for Python 3.7
163
+ if not PY38_PLUS or IS_PYPY and PY38 and not PYPY_7_3_11_PLUS :
164
+ # Not perfect, but best we can do for Python 3.7 and PyPy 3.8 (< v7.3.11).
169
165
# Can't detect closing bracket on new line.
170
166
assert c .fromlineno == 12
171
- elif PY38 and IS_PYPY :
172
- # Not perfect, but best we can do for PyPy 3.8
173
- # Can't detect closing bracket on new line.
174
- assert c .fromlineno == 16
175
167
else :
176
168
assert c .fromlineno == 13
177
169
assert c .tolineno == 14
0 commit comments