Open 4nds opened 9 months ago
The error happens because node
has no attribute doc
,
variable node
is object of class astroid.nodes.Module
,
astroid/astroid/nodes/scoped_nodes/scoped_nodes.py
class Module(LocalsDictNodeNG):
"""Class representing an :class:`ast.Module` node.
and class astroid.nodes.Module
since Astroid version 3.0.0
no longer contains doc
attribute which was depreciated since Astroid 2.11.0
,
Accessing the doc attribute of
nodes.Module
,nodes.ClassDef
, andnodes.FunctionDef
has been deprecated in favour of thedoc_node
attribute. Note:doc_node
is an (optional)nodes.Const
whereasdoc
was an (optional)str
.
astroid/astroid/nodes/scoped_nodes/scoped_nodes.py
@property
def doc(self) -> str | None:
"""The module docstring."""
warnings.warn(
"The 'Module.doc' attribute is deprecated, "
"use 'Module.doc_node' instead.",
DeprecationWarning,
stacklevel=2,
)
return self._doc
and later removed in Astroid 3.0.0
,
Remove deprecated
doc
attribute forModule
,ClassDef
, andFunctionDef
. Use thedoc_node
attribute instead.
Like the deprecation warning says solution is to use doc_node
attribute instead of doc
attribute. So instead of node.doc
in
we need to use node.doc_node
.
Bug description
When parsing the following
utils.py
:The following error occurs with newer Pylint (
>=3.0.0
) and Astroid (>=3.0.0
):Pylint version
OS / Environment
win32 (Windows)
Script used
I used the following script to produce the error for debugging purposes, but the same error occurs when running Pylint in command line or using Pylint extension in Visual Studio Code: