Skip to content

Commit 9cf7d8f

Browse files
Revert "Make Module call the __init__ of NodeNG (pylint-dev#1262)"
This reverts commit dddf2da.
1 parent 9305133 commit 9cf7d8f

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

ChangeLog

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ Release date: TBA
2424

2525
Closes #1260
2626

27-
* Fix ``Module`` nodes not having a ``col_offset``, ``end_lineno``, and ``end_col_offset``
28-
attributes.
29-
3027
* Fix typing and update explanation for ``Arguments.args`` being ``None``.
3128

3229
* Fix crash if a variable named ``type`` is subscripted in a generator expression.

astroid/nodes/scoped_nodes.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,10 @@ class Module(LocalsDictNodeNG):
389389
390390
:type: int or None
391391
"""
392-
lineno: Literal[0] = 0
392+
lineno = 0
393393
"""The line that this node appears on in the source code.
394+
395+
:type: int or None
394396
"""
395397

396398
# attributes below are set by the builder module or by raw factories
@@ -467,6 +469,7 @@ class Module(LocalsDictNodeNG):
467469
)
468470
_other_other_fields = ("locals", "globals")
469471

472+
lineno: None
470473
col_offset: None
471474
end_lineno: None
472475
end_col_offset: None
@@ -509,6 +512,7 @@ def __init__(
509512
self.file = file
510513
self.path = path
511514
self.package = package
515+
self.parent = parent
512516
self.pure_python = pure_python
513517
self.locals = self.globals = {}
514518
"""A map of the name of a local variable to the node defining the local.
@@ -522,8 +526,6 @@ def __init__(
522526
"""
523527
self.future_imports = set()
524528

525-
super().__init__(lineno=0, parent=parent)
526-
527529
# pylint: enable=redefined-builtin
528530

529531
def postinit(self, body=None):

tests/unittest_nodes_lineno.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import pytest
44

5-
import astroid
65
from astroid import builder, nodes
76
from astroid.const import PY38_PLUS, PY39_PLUS, PY310_PLUS
87

@@ -1222,14 +1221,3 @@ class X(Parent, var=42):
12221221
assert (c1.body[0].lineno, c1.body[0].col_offset) == (4, 4)
12231222
assert (c1.body[0].end_lineno, c1.body[0].end_col_offset) == (4, 8)
12241223
# 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

0 commit comments

Comments
 (0)