File tree Expand file tree Collapse file tree 3 files changed +5
-18
lines changed Expand file tree Collapse file tree 3 files changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -24,9 +24,6 @@ Release date: TBA
24
24
25
25
Closes #1260
26
26
27
- * Fix ``Module`` nodes not having a ``col_offset``, ``end_lineno``, and ``end_col_offset``
28
- attributes.
29
-
30
27
* Fix typing and update explanation for ``Arguments.args`` being ``None``.
31
28
32
29
* Fix crash if a variable named ``type`` is subscripted in a generator expression.
Original file line number Diff line number Diff line change @@ -389,8 +389,10 @@ class Module(LocalsDictNodeNG):
389
389
390
390
:type: int or None
391
391
"""
392
- lineno : Literal [ 0 ] = 0
392
+ lineno = 0
393
393
"""The line that this node appears on in the source code.
394
+
395
+ :type: int or None
394
396
"""
395
397
396
398
# attributes below are set by the builder module or by raw factories
@@ -467,6 +469,7 @@ class Module(LocalsDictNodeNG):
467
469
)
468
470
_other_other_fields = ("locals" , "globals" )
469
471
472
+ lineno : None
470
473
col_offset : None
471
474
end_lineno : None
472
475
end_col_offset : None
@@ -509,6 +512,7 @@ def __init__(
509
512
self .file = file
510
513
self .path = path
511
514
self .package = package
515
+ self .parent = parent
512
516
self .pure_python = pure_python
513
517
self .locals = self .globals = {}
514
518
"""A map of the name of a local variable to the node defining the local.
@@ -522,8 +526,6 @@ def __init__(
522
526
"""
523
527
self .future_imports = set ()
524
528
525
- super ().__init__ (lineno = 0 , parent = parent )
526
-
527
529
# pylint: enable=redefined-builtin
528
530
529
531
def postinit (self , body = None ):
Original file line number Diff line number Diff line change 2
2
3
3
import pytest
4
4
5
- import astroid
6
5
from astroid import builder , nodes
7
6
from astroid .const import PY38_PLUS , PY39_PLUS , PY310_PLUS
8
7
@@ -1222,14 +1221,3 @@ class X(Parent, var=42):
1222
1221
assert (c1 .body [0 ].lineno , c1 .body [0 ].col_offset ) == (4 , 4 )
1223
1222
assert (c1 .body [0 ].end_lineno , c1 .body [0 ].end_col_offset ) == (4 , 8 )
1224
1223
# fmt: on
1225
-
1226
- @staticmethod
1227
- def test_end_lineno_module () -> None :
1228
- """Tests for Module"""
1229
- code = """print()"""
1230
- module = astroid .parse (code )
1231
- assert isinstance (module , nodes .Module )
1232
- assert module .lineno == 0
1233
- assert module .col_offset is None
1234
- assert module .end_lineno is None
1235
- assert module .end_col_offset is None
You can’t perform that action at this time.
0 commit comments