Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion astroid/nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ def __init__(
self.file = file
self.path = path
self.package = package
self.parent = parent
self.pure_python = pure_python
self.locals = self.globals = {}
"""A map of the name of a local variable to the node defining the local.
Expand All @@ -526,6 +525,8 @@ def __init__(
"""
self.future_imports = set()

super().__init__(lineno=0, parent=parent)

# pylint: enable=redefined-builtin

def postinit(self, body=None):
Expand Down
12 changes: 12 additions & 0 deletions tests/unittest_nodes_lineno.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

import astroid
from astroid import builder, nodes
from astroid.const import PY38_PLUS, PY39_PLUS, PY310_PLUS

Expand Down Expand Up @@ -1221,3 +1222,14 @@ class X(Parent, var=42):
assert (c1.body[0].lineno, c1.body[0].col_offset) == (4, 4)
assert (c1.body[0].end_lineno, c1.body[0].end_col_offset) == (4, 8)
# fmt: on

@staticmethod
def test_end_lineno_module() -> None:
"""Tests for Module"""
code = """print()"""
module = astroid.parse(code)
assert isinstance(module, nodes.Module)
assert module.lineno == 1
assert module.col_offset is None
assert module.end_lineno is None
assert module.end_col_offset is None