File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ 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+
2730* Fix typing and update explanation for ``Arguments.args`` being ``None``.
2831
2932* Fix crash if a variable named ``type`` is subscripted in a generator expression.
Original file line number Diff line number Diff line change @@ -389,10 +389,8 @@ class Module(LocalsDictNodeNG):
389389
390390 :type: int or None
391391 """
392- lineno = 0
392+ lineno : Literal [ 0 ] = 0
393393 """The line that this node appears on in the source code.
394-
395- :type: int or None
396394 """
397395
398396 # attributes below are set by the builder module or by raw factories
@@ -469,7 +467,6 @@ class Module(LocalsDictNodeNG):
469467 )
470468 _other_other_fields = ("locals" , "globals" )
471469
472- lineno : None
473470 col_offset : None
474471 end_lineno : None
475472 end_col_offset : None
@@ -512,7 +509,6 @@ def __init__(
512509 self .file = file
513510 self .path = path
514511 self .package = package
515- self .parent = parent
516512 self .pure_python = pure_python
517513 self .locals = self .globals = {}
518514 """A map of the name of a local variable to the node defining the local.
@@ -526,6 +522,8 @@ def __init__(
526522 """
527523 self .future_imports = set ()
528524
525+ super ().__init__ (lineno = 0 , parent = parent )
526+
529527 # pylint: enable=redefined-builtin
530528
531529 def postinit (self , body = None ):
Original file line number Diff line number Diff line change 22
33import pytest
44
5+ import astroid
56from astroid import builder , nodes
67from astroid .const import PY38_PLUS , PY39_PLUS , PY310_PLUS
78
@@ -1221,3 +1222,14 @@ class X(Parent, var=42):
12211222 assert (c1 .body [0 ].lineno , c1 .body [0 ].col_offset ) == (4 , 4 )
12221223 assert (c1 .body [0 ].end_lineno , c1 .body [0 ].end_col_offset ) == (4 , 8 )
12231224 # 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