prompt: Deprecation warnings from numpy
  ### Steps to reproduce
  
  1. Run pylint over the following test case:
  
  ```
  """Test case"""
  
  import numpy as np
  value = np.random.seed(1234)
  ```
  
  ### Current behavior
  ```
  /home/bje/source/nemo/myenv/lib/python3.10/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
    getattr(sys.modules[modname], name)
  /home/bje/source/nemo/myenv/lib/python3.10/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
    getattr(sys.modules[modname], name)
  ```
  
  ### Expected behavior
  There should be no future warnings.
  
  ### python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output
  2.12.13
  
instance: {"FAIL_TO_PASS": "[\"tests/unittest_raw_building.py::test_build_module_getattr_catch_output\"]", "PASS_TO_PASS": "[\"tests/unittest_raw_building.py::RawBuildingTC::test_attach_dummy_node\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_class\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_from_import\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_function\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_function_args\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_function_deepinspect_deprecation\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_function_defaults\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_function_kwonlyargs\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_function_posonlyargs\", \"tests/unittest_raw_building.py::RawBuildingTC::test_build_module\", \"tests/unittest_raw_building.py::RawBuildingTC::test_io_is__io\", \"tests/unittest_raw_building.py::RawBuildingTC::test_module_object_with_broken_getattr\"]", "base_commit": "0c9ab0fe56703fa83c73e514a1020d398d23fa7f", "created_at": "2023-01-28T06:14:39Z", "environment_setup_commit": "0c9ab0fe56703fa83c73e514a1020d398d23fa7f", "hints_text": "This seems very similar to https://github.com/PyCQA/astroid/pull/1514 that was fixed in 2.12.0.\nI'm running 2.12.13 (> 2.12.0), so the fix isn't working in this case?\nI don't know why #1514 did not fix this, I think we were capturing both stdout and stderr, so this will need some investigation. My guess would be that there's somewhere else to apply the same method to.\nHello, \r\nI see the same error with pylint on our tool [demcompare](https://github.com/CNES/demcompare). Pylint version:\r\n```\r\npylint --version\r\npylint 2.15.9\r\nastroid 2.12.13\r\nPython 3.8.10 (default, Nov 14 2022, 12:59:47) \r\n[GCC 9.4.0]\r\n```\r\nI confirm the weird astroid lower warning and I don't know how to bypass it with pylint checking. \r\n\r\n```\r\npylint demcompare \r\n/home/duboise/work/src/demcompare/venv/lib/python3.8/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.\r\n  getattr(sys.modules[modname], name)\r\n... (four times)\r\n```\r\n\r\nThanks in advance if there is a solution\r\nCordially\r\n\n> Thanks in advance if there is a solution\r\n\r\nwhile annoying the warning does not make pylint fail. Just ignore it. In a CI you can just check pylint return code. It will return 0 as expected\nI agree, even if annoying because it feels our code as a problem somewhere, the CI with pylint doesn't fail indeed. Thanks for the answer that confirm to not bother for now. \nThat might be fine in a CI environment, but for users, ultimately, ignoring warnings becomes difficult when there are too many such warnings. I would like to see this fixed.\nOh, it was not an argument in favour of not fixing it. It was just to point out that it is not a breaking problem. It is \"just\" a lot of quite annoying warnings. I am following the issue because it annoys me too. So I am in the same \"I hope they will fix it\" boat\n> I don't know why https://github.com/PyCQA/astroid/pull/1514 did not fix this, I think we were capturing both stdout and stderr, so this will need some investigation. My guess would be that there's somewhere else to apply the same method to.\r\n\r\nThat PR only addressed import-time. This `FutureWarning` is emitted by numpy's package-level `__getattr__` method, not during import.", "instance_id": "pylint-dev__astroid-1978", "patch": "diff --git a/astroid/raw_building.py b/astroid/raw_building.py\n--- a/astroid/raw_building.py\n+++ b/astroid/raw_building.py\n@@ -10,11 +10,14 @@\n \n import builtins\n import inspect\n+import io\n+import logging\n import os\n import sys\n import types\n import warnings\n from collections.abc import Iterable\n+from contextlib import redirect_stderr, redirect_stdout\n from typing import Any, Union\n \n from astroid import bases, nodes\n@@ -22,6 +25,9 @@\n from astroid.manager import AstroidManager\n from astroid.nodes import node_classes\n \n+logger = logging.getLogger(__name__)\n+\n+\n _FunctionTypes = Union[\n     types.FunctionType,\n     types.MethodType,\n@@ -471,7 +477,26 @@ def imported_member(self, node, member, name: str) -> bool:\n             # check if it sounds valid and then add an import node, else use a\n             # dummy node\n             try:\n-                getattr(sys.modules[modname], name)\n+                with redirect_stderr(io.StringIO()) as stderr, redirect_stdout(\n+                    io.StringIO()\n+                ) as stdout:\n+                    getattr(sys.modules[modname], name)\n+                    stderr_value = stderr.getvalue()\n+                    if stderr_value:\n+                        logger.error(\n+                            \"Captured stderr while getting %s from %s:\\n%s\",\n+                            name,\n+                            sys.modules[modname],\n+                            stderr_value,\n+                        )\n+                    stdout_value = stdout.getvalue()\n+                    if stdout_value:\n+                        logger.info(\n+                            \"Captured stdout while getting %s from %s:\\n%s\",\n+                            name,\n+                            sys.modules[modname],\n+                            stdout_value,\n+                        )\n             except (KeyError, AttributeError):\n                 attach_dummy_node(node, name, member)\n             else:\n", "problem_statement": "Deprecation warnings from numpy\n### Steps to reproduce\r\n\r\n1. Run pylint over the following test case:\r\n\r\n```\r\n\"\"\"Test case\"\"\"\r\n\r\nimport numpy as np\r\nvalue = np.random.seed(1234)\r\n```\r\n\r\n### Current behavior\r\n```\r\n/home/bje/source/nemo/myenv/lib/python3.10/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.\r\n  getattr(sys.modules[modname], name)\r\n/home/bje/source/nemo/myenv/lib/python3.10/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.\r\n  getattr(sys.modules[modname], name)\r\n```\r\n\r\n### Expected behavior\r\nThere should be no future warnings.\r\n\r\n### python -c \"from astroid import __pkginfo__; print(__pkginfo__.version)\" output\r\n2.12.13\n", "repo": "pylint-dev/astroid", "test_patch": "diff --git a/tests/unittest_raw_building.py b/tests/unittest_raw_building.py\n--- a/tests/unittest_raw_building.py\n+++ b/tests/unittest_raw_building.py\n@@ -8,8 +8,15 @@\n # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE\n # Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt\n \n+from __future__ import annotations\n+\n+import logging\n+import os\n+import sys\n import types\n import unittest\n+from typing import Any\n+from unittest import mock\n \n import _io\n import pytest\n@@ -117,5 +124,45 @@ def test_module_object_with_broken_getattr(self) -> None:\n         AstroidBuilder().inspect_build(fm_getattr, \"test\")\n \n \n+@pytest.mark.skipif(\n+    \"posix\" not in sys.builtin_module_names, reason=\"Platform doesn't support posix\"\n+)\n+def test_build_module_getattr_catch_output(\n+    capsys: pytest.CaptureFixture[str],\n+    caplog: pytest.LogCaptureFixture,\n+) -> None:\n+    \"\"\"Catch stdout and stderr in module __getattr__ calls when building a module.\n+\n+    Usually raised by DeprecationWarning or FutureWarning.\n+    \"\"\"\n+    caplog.set_level(logging.INFO)\n+    original_sys = sys.modules\n+    original_module = sys.modules[\"posix\"]\n+    expected_out = \"INFO (TEST): Welcome to posix!\"\n+    expected_err = \"WARNING (TEST): Monkey-patched version of posix - module getattr\"\n+\n+    class CustomGetattr:\n+        def __getattr__(self, name: str) -> Any:\n+            print(f\"{expected_out}\")\n+            print(expected_err, file=sys.stderr)\n+            return getattr(original_module, name)\n+\n+    def mocked_sys_modules_getitem(name: str) -> types.ModuleType | CustomGetattr:\n+        if name != \"posix\":\n+            return original_sys[name]\n+        return CustomGetattr()\n+\n+    with mock.patch(\"astroid.raw_building.sys.modules\") as sys_mock:\n+        sys_mock.__getitem__.side_effect = mocked_sys_modules_getitem\n+        builder = AstroidBuilder()\n+        builder.inspect_build(os)\n+\n+    out, err = capsys.readouterr()\n+    assert expected_out in caplog.text\n+    assert expected_err in caplog.text\n+    assert not out\n+    assert not err\n+\n+\n if __name__ == \"__main__\":\n     unittest.main()\n", "version": "2.14"}
parsed_commit_content: {"file_diffs":[{"old_file_content":"# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html\n# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE\n# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt\n\n\"\"\"this module contains a set of functions to create astroid trees from scratch\n(build_* functions) or from living object (object_build_* functions)\n\"\"\"\n\nfrom __future__ import annotations\n\nimport builtins\nimport inspect\nimport os\nimport sys\nimport types\nimport warnings\nfrom collections.abc import Iterable\nfrom typing import Any, Union\n\nfrom astroid import bases, nodes\nfrom astroid.const import _EMPTY_OBJECT_MARKER, IS_PYPY\nfrom astroid.manager import AstroidManager\nfrom astroid.nodes import node_classes\n\n_FunctionTypes = Union[\n    types.FunctionType,\n    types.MethodType,\n    types.BuiltinFunctionType,\n    types.WrapperDescriptorType,\n    types.MethodDescriptorType,\n    types.ClassMethodDescriptorType,\n]\n\n# the keys of CONST_CLS eg python builtin types\n_CONSTANTS = tuple(node_classes.CONST_CLS)\n_BUILTINS = vars(builtins)\nTYPE_NONE = type(None)\nTYPE_NOTIMPLEMENTED = type(NotImplemented)\nTYPE_ELLIPSIS = type(...)\n\n\ndef _attach_local_node(parent, node, name: str) -> None:\n    node.name = name  # needed by add_local_node\n    parent.add_local_node(node)\n\n\ndef _add_dunder_class(func, member) -> None:\n    \"\"\"Add a __class__ member to the given func node, if we can determine it.\"\"\"\n    python_cls = member.__class__\n    cls_name = getattr(python_cls, \"__name__\", None)\n    if not cls_name:\n        return\n    cls_bases = [ancestor.__name__ for ancestor in python_cls.__bases__]\n    ast_klass = build_class(cls_name, cls_bases, python_cls.__doc__)\n    func.instance_attrs[\"__class__\"] = [ast_klass]\n\n\ndef attach_dummy_node(node, name: str, runtime_object=_EMPTY_OBJECT_MARKER) -> None:\n    \"\"\"create a dummy node and register it in the locals of the given\n    node with the specified name\n    \"\"\"\n    enode = nodes.EmptyNode()\n    enode.object = runtime_object\n    _attach_local_node(node, enode, name)\n\n\ndef attach_const_node(node, name: str, value) -> None:\n    \"\"\"create a Const node and register it in the locals of the given\n    node with the specified name\n    \"\"\"\n    if name not in node.special_attributes:\n        _attach_local_node(node, nodes.const_factory(value), name)\n\n\ndef attach_import_node(node, modname: str, membername: str) -> None:\n    \"\"\"create a ImportFrom node and register it in the locals of the given\n    node with the specified name\n    \"\"\"\n    from_node = nodes.ImportFrom(modname, [(membername, None)])\n    _attach_local_node(node, from_node, membername)\n\n\ndef build_module(name: str, doc: str | None = None) -> nodes.Module:\n    \"\"\"create and initialize an astroid Module node\"\"\"\n    node = nodes.Module(name, pure_python=False, package=False)\n    node.postinit(\n        body=[],\n        doc_node=nodes.Const(value=doc) if doc else None,\n    )\n    return node\n\n\ndef build_class(\n    name: str, basenames: Iterable[str] = (), doc: str | None = None\n) -> nodes.ClassDef:\n    \"\"\"Create and initialize an astroid ClassDef node.\"\"\"\n    node = nodes.ClassDef(name)\n    node.postinit(\n        bases=[nodes.Name(name=base, parent=node) for base in basenames],\n        body=[],\n        decorators=None,\n        doc_node=nodes.Const(value=doc) if doc else None,\n    )\n    return node\n\n\ndef build_function(\n    name: str,\n    args: list[str] | None = None,\n    posonlyargs: list[str] | None = None,\n    defaults: list[Any] | None = None,\n    doc: str | None = None,\n    kwonlyargs: list[str] | None = None,\n) -> nodes.FunctionDef:\n    \"\"\"create and initialize an astroid FunctionDef node\"\"\"\n    # first argument is now a list of decorators\n    func = nodes.FunctionDef(name)\n    argsnode = nodes.Arguments(parent=func)\n\n    # If args is None we don't have any information about the signature\n    # (in contrast to when there are no arguments and args == []). We pass\n    # this to the builder to indicate this.\n    if args is not None:\n        arguments = [nodes.AssignName(name=arg, parent=argsnode) for arg in args]\n    else:\n        arguments = None\n\n    default_nodes: list[nodes.NodeNG] | None = []\n    if defaults is not None:\n        for default in defaults:\n            default_node = nodes.const_factory(default)\n            default_node.parent = argsnode\n            default_nodes.append(default_node)\n    else:\n        default_nodes = None\n\n    argsnode.postinit(\n        args=arguments,\n        defaults=default_nodes,\n        kwonlyargs=[\n            nodes.AssignName(name=arg, parent=argsnode) for arg in kwonlyargs or ()\n        ],\n        kw_defaults=[],\n        annotations=[],\n        posonlyargs=[\n            nodes.AssignName(name=arg, parent=argsnode) for arg in posonlyargs or ()\n        ],\n    )\n    func.postinit(\n        args=argsnode,\n        body=[],\n        doc_node=nodes.Const(value=doc) if doc else None,\n    )\n    if args:\n        register_arguments(func)\n    return func\n\n\ndef build_from_import(fromname: str, names: list[str]) -> nodes.ImportFrom:\n    \"\"\"create and initialize an astroid ImportFrom import statement\"\"\"\n    return nodes.ImportFrom(fromname, [(name, None) for name in names])\n\n\ndef register_arguments(func: nodes.FunctionDef, args: list | None = None) -> None:\n    \"\"\"add given arguments to local\n\n    args is a list that may contains nested lists\n    (i.e. def func(a, (b, c, d)): ...)\n    \"\"\"\n    # If no args are passed in, get the args from the function.\n    if args is None:\n        if func.args.vararg:\n            func.set_local(func.args.vararg, func.args)\n        if func.args.kwarg:\n            func.set_local(func.args.kwarg, func.args)\n        args = func.args.args\n        # If the function has no args, there is nothing left to do.\n        if args is None:\n            return\n    for arg in args:\n        if isinstance(arg, nodes.AssignName):\n            func.set_local(arg.name, arg)\n        else:\n            register_arguments(func, arg.elts)\n\n\ndef object_build_class(\n    node: nodes.Module | nodes.ClassDef, member: type, localname: str\n) -> nodes.ClassDef:\n    \"\"\"create astroid for a living class object\"\"\"\n    basenames = [base.__name__ for base in member.__bases__]\n    return _base_class_object_build(node, member, basenames, localname=localname)\n\n\ndef _get_args_info_from_callable(\n    member: _FunctionTypes,\n) -> tuple[list[str], list[str], list[Any], list[str]]:\n    \"\"\"Returns args, posonlyargs, defaults, kwonlyargs.\n\n    :note: currently ignores the return annotation.\n    \"\"\"\n    signature = inspect.signature(member)\n    args: list[str] = []\n    defaults: list[Any] = []\n    posonlyargs: list[str] = []\n    kwonlyargs: list[str] = []\n\n    for param_name, param in signature.parameters.items():\n        if param.kind == inspect.Parameter.POSITIONAL_ONLY:\n            posonlyargs.append(param_name)\n        elif param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD:\n            args.append(param_name)\n        elif param.kind == inspect.Parameter.VAR_POSITIONAL:\n            args.append(param_name)\n        elif param.kind == inspect.Parameter.VAR_KEYWORD:\n            args.append(param_name)\n        elif param.kind == inspect.Parameter.KEYWORD_ONLY:\n            kwonlyargs.append(param_name)\n        if param.default is not inspect._empty:\n            defaults.append(param.default)\n\n    return args, posonlyargs, defaults, kwonlyargs\n\n\ndef object_build_function(\n    node: nodes.Module | nodes.ClassDef, member: _FunctionTypes, localname: str\n) -> None:\n    \"\"\"create astroid for a living function object\"\"\"\n    args, posonlyargs, defaults, kwonlyargs = _get_args_info_from_callable(member)\n\n    func = build_function(\n        getattr(member, \"__name__\", None) or localname,\n        args,\n        posonlyargs,\n        defaults,\n        member.__doc__,\n        kwonlyargs=kwonlyargs,\n    )\n\n    node.add_local_node(func, localname)\n\n\ndef object_build_datadescriptor(\n    node: nodes.Module | nodes.ClassDef, member: type, name: str\n) -> nodes.ClassDef:\n    \"\"\"create astroid for a living data descriptor object\"\"\"\n    return _base_class_object_build(node, member, [], name)\n\n\ndef object_build_methoddescriptor(\n    node: nodes.Module | nodes.ClassDef,\n    member: _FunctionTypes,\n    localname: str,\n) -> None:\n    \"\"\"create astroid for a living method descriptor object\"\"\"\n    # FIXME get arguments ?\n    func = build_function(\n        getattr(member, \"__name__\", None) or localname, doc=member.__doc__\n    )\n    node.add_local_node(func, localname)\n    _add_dunder_class(func, member)\n\n\ndef _base_class_object_build(\n    node: nodes.Module | nodes.ClassDef,\n    member: type,\n    basenames: list[str],\n    name: str | None = None,\n    localname: str | None = None,\n) -> nodes.ClassDef:\n    \"\"\"create astroid for a living class object, with a given set of base names\n    (e.g. ancestors)\n    \"\"\"\n    class_name = name or getattr(member, \"__name__\", None) or localname\n    assert isinstance(class_name, str)\n    klass = build_class(\n        class_name,\n        basenames,\n        member.__doc__,\n    )\n    klass._newstyle = isinstance(member, type)\n    node.add_local_node(klass, localname)\n    try:\n        # limit the instantiation trick since it's too dangerous\n        # (such as infinite test execution...)\n        # this at least resolves common case such as Exception.args,\n        # OSError.errno\n        if issubclass(member, Exception):\n            instdict = member().__dict__\n        else:\n            raise TypeError\n    except TypeError:\n        pass\n    else:\n        for item_name, obj in instdict.items():\n            valnode = nodes.EmptyNode()\n            valnode.object = obj\n            valnode.parent = klass\n            valnode.lineno = 1\n            klass.instance_attrs[item_name] = [valnode]\n    return klass\n\n\ndef _build_from_function(\n    node: nodes.Module | nodes.ClassDef,\n    name: str,\n    member: _FunctionTypes,\n    module: types.ModuleType,\n) -> None:\n    # verify this is not an imported function\n    try:\n        code = member.__code__  # type: ignore[union-attr]\n    except AttributeError:\n        # Some implementations don't provide the code object,\n        # such as Jython.\n        code = None\n    filename = getattr(code, \"co_filename\", None)\n    if filename is None:\n        assert isinstance(member, object)\n        object_build_methoddescriptor(node, member, name)\n    elif filename != getattr(module, \"__file__\", None):\n        attach_dummy_node(node, name, member)\n    else:\n        object_build_function(node, member, name)\n\n\ndef _safe_has_attribute(obj, member: str) -> bool:\n    \"\"\"Required because unexpected RunTimeError can be raised.\n\n    See https://github.com/PyCQA/astroid/issues/1958\n    \"\"\"\n    try:\n        return hasattr(obj, member)\n    except Exception:  # pylint: disable=broad-except\n        return False\n\n\nclass InspectBuilder:\n    \"\"\"class for building nodes from living object\n\n    this is actually a really minimal representation, including only Module,\n    FunctionDef and ClassDef nodes and some others as guessed.\n    \"\"\"\n\n    def __init__(self, manager_instance: AstroidManager | None = None) -> None:\n        self._manager = manager_instance or AstroidManager()\n        self._done: dict[types.ModuleType | type, nodes.Module | nodes.ClassDef] = {}\n        self._module: types.ModuleType\n\n    def inspect_build(\n        self,\n        module: types.ModuleType,\n        modname: str | None = None,\n        path: str | None = None,\n    ) -> nodes.Module:\n        \"\"\"build astroid from a living module (i.e. using inspect)\n        this is used when there is no python source code available (either\n        because it's a built-in module or because the .py is not available)\n        \"\"\"\n        self._module = module\n        if modname is None:\n            modname = module.__name__\n        try:\n            node = build_module(modname, module.__doc__)\n        except AttributeError:\n            # in jython, java modules have no __doc__ (see #109562)\n            node = build_module(modname)\n        if path is None:\n            node.path = node.file = path\n        else:\n            node.path = [os.path.abspath(path)]\n            node.file = node.path[0]\n        node.name = modname\n        self._manager.cache_module(node)\n        node.package = hasattr(module, \"__path__\")\n        self._done = {}\n        self.object_build(node, module)\n        return node\n\n    def object_build(\n        self, node: nodes.Module | nodes.ClassDef, obj: types.ModuleType | type\n    ) -> None:\n        \"\"\"recursive method which create a partial ast from real objects\n        (only function, class, and method are handled)\n        \"\"\"\n        if obj in self._done:\n            return None\n        self._done[obj] = node\n        for name in dir(obj):\n            # inspect.ismethod() and inspect.isbuiltin() in PyPy return\n            # the opposite of what they do in CPython for __class_getitem__.\n            pypy__class_getitem__ = IS_PYPY and name == \"__class_getitem__\"\n            try:\n                with warnings.catch_warnings():\n                    warnings.simplefilter(\"ignore\")\n                    member = getattr(obj, name)\n            except AttributeError:\n                # damned ExtensionClass.Base, I know you're there !\n                attach_dummy_node(node, name)\n                continue\n            if inspect.ismethod(member) and not pypy__class_getitem__:\n                member = member.__func__\n            if inspect.isfunction(member):\n                _build_from_function(node, name, member, self._module)\n            elif inspect.isbuiltin(member) or pypy__class_getitem__:\n                if self.imported_member(node, member, name):\n                    continue\n                object_build_methoddescriptor(node, member, name)\n            elif inspect.isclass(member):\n                if self.imported_member(node, member, name):\n                    continue\n                if member in self._done:\n                    class_node = self._done[member]\n                    assert isinstance(class_node, nodes.ClassDef)\n                    if class_node not in node.locals.get(name, ()):\n                        node.add_local_node(class_node, name)\n                else:\n                    class_node = object_build_class(node, member, name)\n                    # recursion\n                    self.object_build(class_node, member)\n                if name == \"__class__\" and class_node.parent is None:\n                    class_node.parent = self._done[self._module]\n            elif inspect.ismethoddescriptor(member):\n                object_build_methoddescriptor(node, member, name)\n            elif inspect.isdatadescriptor(member):\n                object_build_datadescriptor(node, member, name)\n            elif isinstance(member, _CONSTANTS):\n                attach_const_node(node, name, member)\n            elif inspect.isroutine(member):\n                # This should be called for Jython, where some builtin\n                # methods aren't caught by isbuiltin branch.\n                _build_from_function(node, name, member, self._module)\n            elif _safe_has_attribute(member, \"__all__\"):\n                module = build_module(name)\n                _attach_local_node(node, module, name)\n                # recursion\n                self.object_build(module, member)\n            else:\n                # create an empty node so that the name is actually defined\n                attach_dummy_node(node, name, member)\n        return None\n\n    def imported_member(self, node, member, name: str) -> bool:\n        \"\"\"verify this is not an imported class or handle it\"\"\"\n        # /!\\ some classes like ExtensionClass doesn't have a __module__\n        # attribute ! Also, this may trigger an exception on badly built module\n        # (see http://www.logilab.org/ticket/57299 for instance)\n        try:\n            modname = getattr(member, \"__module__\", None)\n        except TypeError:\n            modname = None\n        if modname is None:\n            if name in {\"__new__\", \"__subclasshook__\"}:\n                # Python 2.5.1 (r251:54863, Sep  1 2010, 22:03:14)\n                # >>> print object.__new__.__module__\n                # None\n                modname = builtins.__name__\n            else:\n                attach_dummy_node(node, name, member)\n                return True\n\n        # On PyPy during bootstrapping we infer _io while _module is\n        # builtins. In CPython _io names itself io, see http://bugs.python.org/issue18602\n        # Therefore, this basically checks whether we are not in PyPy.\n        if modname == \"_io\" and not self._module.__name__ == \"builtins\":\n            return False\n\n        real_name = {\"gtk\": \"gtk_gtk\"}.get(modname, modname)\n\n        if real_name != self._module.__name__:\n            # check if it sounds valid and then add an import node, else use a\n            # dummy node\n            try:\n                getattr(sys.modules[modname], name)\n            except (KeyError, AttributeError):\n                attach_dummy_node(node, name, member)\n            else:\n                attach_import_node(node, modname, name)\n            return True\n        return False\n\n\n# astroid bootstrapping ######################################################\n\n_CONST_PROXY: dict[type, nodes.ClassDef] = {}\n\n\ndef _set_proxied(const) -> nodes.ClassDef:\n    # TODO : find a nicer way to handle this situation;\n    return _CONST_PROXY[const.value.__class__]\n\n\ndef _astroid_bootstrapping() -> None:\n    \"\"\"astroid bootstrapping the builtins module\"\"\"\n    # this boot strapping is necessary since we need the Const nodes to\n    # inspect_build builtins, and then we can proxy Const\n    builder = InspectBuilder()\n    astroid_builtin = builder.inspect_build(builtins)\n\n    for cls, node_cls in node_classes.CONST_CLS.items():\n        if cls is TYPE_NONE:\n            proxy = build_class(\"NoneType\")\n            proxy.parent = astroid_builtin\n        elif cls is TYPE_NOTIMPLEMENTED:\n            proxy = build_class(\"NotImplementedType\")\n            proxy.parent = astroid_builtin\n        elif cls is TYPE_ELLIPSIS:\n            proxy = build_class(\"Ellipsis\")\n            proxy.parent = astroid_builtin\n        else:\n            proxy = astroid_builtin.getattr(cls.__name__)[0]\n            assert isinstance(proxy, nodes.ClassDef)\n        if cls in (dict, list, set, tuple):\n            node_cls._proxied = proxy\n        else:\n            _CONST_PROXY[cls] = proxy\n\n    # Set the builtin module as parent for some builtins.\n    nodes.Const._proxied = property(_set_proxied)\n\n    _GeneratorType = nodes.ClassDef(types.GeneratorType.__name__)\n    _GeneratorType.parent = astroid_builtin\n    generator_doc_node = (\n        nodes.Const(value=types.GeneratorType.__doc__)\n        if types.GeneratorType.__doc__\n        else None\n    )\n    _GeneratorType.postinit(\n        bases=[],\n        body=[],\n        decorators=None,\n        doc_node=generator_doc_node,\n    )\n    bases.Generator._proxied = _GeneratorType\n    builder.object_build(bases.Generator._proxied, types.GeneratorType)\n\n    if hasattr(types, \"AsyncGeneratorType\"):\n        _AsyncGeneratorType = nodes.ClassDef(types.AsyncGeneratorType.__name__)\n        _AsyncGeneratorType.parent = astroid_builtin\n        async_generator_doc_node = (\n            nodes.Const(value=types.AsyncGeneratorType.__doc__)\n            if types.AsyncGeneratorType.__doc__\n            else None\n        )\n        _AsyncGeneratorType.postinit(\n            bases=[],\n            body=[],\n            decorators=None,\n            doc_node=async_generator_doc_node,\n        )\n        bases.AsyncGenerator._proxied = _AsyncGeneratorType\n        builder.object_build(bases.AsyncGenerator._proxied, types.AsyncGeneratorType)\n    builtin_types = (\n        types.GetSetDescriptorType,\n        types.GeneratorType,\n        types.MemberDescriptorType,\n        TYPE_NONE,\n        TYPE_NOTIMPLEMENTED,\n        types.FunctionType,\n        types.MethodType,\n        types.BuiltinFunctionType,\n        types.ModuleType,\n        types.TracebackType,\n    )\n    for _type in builtin_types:\n        if _type.__name__ not in astroid_builtin:\n            klass = nodes.ClassDef(_type.__name__)\n            klass.parent = astroid_builtin\n            klass.postinit(\n                bases=[],\n                body=[],\n                decorators=None,\n                doc_node=nodes.Const(value=_type.__doc__) if _type.__doc__ else None,\n            )\n            builder.object_build(klass, _type)\n            astroid_builtin[_type.__name__] = klass\n\n\n_astroid_bootstrapping()\n","new_file_content":"# Copyright (c) 2006-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>\n# Copyright (c) 2012 FELD Boris <lothiraldan@gmail.com>\n# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com>\n# Copyright (c) 2014 Google, Inc.\n# Copyright (c) 2015-2016 Ceridwen <ceridwenv@gmail.com>\n# Copyright (c) 2015 Florian Bruhin <me@the-compiler.org>\n# Copyright (c) 2015 Ovidiu Sabou <ovidiu@sabou.org>\n# Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com>\n# Copyright (c) 2016 Jakub Wilk <jwilk@jwilk.net>\n# Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi>\n# Copyright (c) 2018 Nick Drozd <nicholasdrozd@gmail.com>\n# Copyright (c) 2018 Bryce Guinta <bryce.paul.guinta@gmail.com>\n# Copyright (c) 2020-2021 hippo91 <guillaume.peillex@gmail.com>\n# Copyright (c) 2020 Becker Awqatty <bawqatty@mide.com>\n# Copyright (c) 2020 Robin Jarry <robin.jarry@6wind.com>\n# Copyright (c) 2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>\n# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>\n# Copyright (c) 2021 Andrew Haigh <hello@nelf.in>\n\n# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html\n# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE\n\n\"\"\"this module contains a set of functions to create astroid trees from scratch\n(build_* functions) or from living object (object_build_* functions)\n\"\"\"\n\nimport builtins\nimport inspect\nimport os\nimport sys\nimport types\nimport warnings\nfrom typing import List, Optional\n\nfrom astroid import bases, nodes\nfrom astroid.manager import AstroidManager\nfrom astroid.nodes import node_classes\n\n# the keys of CONST_CLS eg python builtin types\n_CONSTANTS = tuple(node_classes.CONST_CLS)\n_BUILTINS = vars(builtins)\nTYPE_NONE = type(None)\nTYPE_NOTIMPLEMENTED = type(NotImplemented)\nTYPE_ELLIPSIS = type(...)\n\n\ndef _io_discrepancy(member):\n    # _io module names itself `io`: http://bugs.python.org/issue18602\n    member_self = getattr(member, \"__self__\", None)\n    return (\n        member_self\n        and inspect.ismodule(member_self)\n        and member_self.__name__ == \"_io\"\n        and member.__module__ == \"io\"\n    )\n\n\ndef _attach_local_node(parent, node, name):\n    node.name = name  # needed by add_local_node\n    parent.add_local_node(node)\n\n\ndef _add_dunder_class(func, member):\n    \"\"\"Add a __class__ member to the given func node, if we can determine it.\"\"\"\n    python_cls = member.__class__\n    cls_name = getattr(python_cls, \"__name__\", None)\n    if not cls_name:\n        return\n    cls_bases = [ancestor.__name__ for ancestor in python_cls.__bases__]\n    ast_klass = build_class(cls_name, cls_bases, python_cls.__doc__)\n    func.instance_attrs[\"__class__\"] = [ast_klass]\n\n\n_marker = object()\n\n\ndef attach_dummy_node(node, name, runtime_object=_marker):\n    \"\"\"create a dummy node and register it in the locals of the given\n    node with the specified name\n    \"\"\"\n    enode = nodes.EmptyNode()\n    enode.object = runtime_object\n    _attach_local_node(node, enode, name)\n\n\ndef _has_underlying_object(self):\n    return self.object is not None and self.object is not _marker\n\n\nnodes.EmptyNode.has_underlying_object = _has_underlying_object\n\n\ndef attach_const_node(node, name, value):\n    \"\"\"create a Const node and register it in the locals of the given\n    node with the specified name\n    \"\"\"\n    if name not in node.special_attributes:\n        _attach_local_node(node, nodes.const_factory(value), name)\n\n\ndef attach_import_node(node, modname, membername):\n    \"\"\"create a ImportFrom node and register it in the locals of the given\n    node with the specified name\n    \"\"\"\n    from_node = nodes.ImportFrom(modname, [(membername, None)])\n    _attach_local_node(node, from_node, membername)\n\n\ndef build_module(name: str, doc: str = None) -> nodes.Module:\n    \"\"\"create and initialize an astroid Module node\"\"\"\n    node = nodes.Module(name, doc, pure_python=False)\n    node.package = False\n    node.parent = None\n    return node\n\n\ndef build_class(name, basenames=(), doc=None):\n    \"\"\"create and initialize an astroid ClassDef node\"\"\"\n    node = nodes.ClassDef(name, doc)\n    for base in basenames:\n        basenode = nodes.Name(name=base)\n        node.bases.append(basenode)\n        basenode.parent = node\n    return node\n\n\ndef build_function(\n    name,\n    args: Optional[List[str]] = None,\n    posonlyargs: Optional[List[str]] = None,\n    defaults=None,\n    doc=None,\n    kwonlyargs: Optional[List[str]] = None,\n) -> nodes.FunctionDef:\n    \"\"\"create and initialize an astroid FunctionDef node\"\"\"\n    # first argument is now a list of decorators\n    func = nodes.FunctionDef(name, doc)\n    func.args = argsnode = nodes.Arguments(parent=func)\n    argsnode.postinit(\n        args=[nodes.AssignName(name=arg, parent=argsnode) for arg in args or ()],\n        defaults=[],\n        kwonlyargs=[\n            nodes.AssignName(name=arg, parent=argsnode) for arg in kwonlyargs or ()\n        ],\n        kw_defaults=[],\n        annotations=[],\n        posonlyargs=[\n            nodes.AssignName(name=arg, parent=argsnode) for arg in posonlyargs or ()\n        ],\n    )\n    for default in defaults or ():\n        argsnode.defaults.append(nodes.const_factory(default))\n        argsnode.defaults[-1].parent = argsnode\n    if args:\n        register_arguments(func)\n    return func\n\n\ndef build_from_import(fromname, names):\n    \"\"\"create and initialize an astroid ImportFrom import statement\"\"\"\n    return nodes.ImportFrom(fromname, [(name, None) for name in names])\n\n\ndef register_arguments(func, args=None):\n    \"\"\"add given arguments to local\n\n    args is a list that may contains nested lists\n    (i.e. def func(a, (b, c, d)): ...)\n    \"\"\"\n    if args is None:\n        args = func.args.args\n        if func.args.vararg:\n            func.set_local(func.args.vararg, func.args)\n        if func.args.kwarg:\n            func.set_local(func.args.kwarg, func.args)\n    for arg in args:\n        if isinstance(arg, nodes.AssignName):\n            func.set_local(arg.name, arg)\n        else:\n            register_arguments(func, arg.elts)\n\n\ndef object_build_class(node, member, localname):\n    \"\"\"create astroid for a living class object\"\"\"\n    basenames = [base.__name__ for base in member.__bases__]\n    return _base_class_object_build(node, member, basenames, localname=localname)\n\n\ndef object_build_function(node, member, localname):\n    \"\"\"create astroid for a living function object\"\"\"\n    signature = inspect.signature(member)\n    args = []\n    defaults = []\n    posonlyargs = []\n    kwonlyargs = []\n    for param_name, param in signature.parameters.items():\n        if param.kind == inspect.Parameter.POSITIONAL_ONLY:\n            posonlyargs.append(param_name)\n        elif param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD:\n            args.append(param_name)\n        elif param.kind == inspect.Parameter.VAR_POSITIONAL:\n            args.append(param_name)\n        elif param.kind == inspect.Parameter.VAR_KEYWORD:\n            args.append(param_name)\n        elif param.kind == inspect.Parameter.KEYWORD_ONLY:\n            kwonlyargs.append(param_name)\n        if param.default is not inspect._empty:\n            defaults.append(param.default)\n    func = build_function(\n        getattr(member, \"__name__\", None) or localname,\n        args,\n        posonlyargs,\n        defaults,\n        member.__doc__,\n    )\n    node.add_local_node(func, localname)\n\n\ndef object_build_datadescriptor(node, member, name):\n    \"\"\"create astroid for a living data descriptor object\"\"\"\n    return _base_class_object_build(node, member, [], name)\n\n\ndef object_build_methoddescriptor(node, member, localname):\n    \"\"\"create astroid for a living method descriptor object\"\"\"\n    # FIXME get arguments ?\n    func = build_function(\n        getattr(member, \"__name__\", None) or localname, doc=member.__doc__\n    )\n    # set node's arguments to None to notice that we have no information, not\n    # and empty argument list\n    func.args.args = None\n    node.add_local_node(func, localname)\n    _add_dunder_class(func, member)\n\n\ndef _base_class_object_build(node, member, basenames, name=None, localname=None):\n    \"\"\"create astroid for a living class object, with a given set of base names\n    (e.g. ancestors)\n    \"\"\"\n    klass = build_class(\n        name or getattr(member, \"__name__\", None) or localname,\n        basenames,\n        member.__doc__,\n    )\n    klass._newstyle = isinstance(member, type)\n    node.add_local_node(klass, localname)\n    try:\n        # limit the instantiation trick since it's too dangerous\n        # (such as infinite test execution...)\n        # this at least resolves common case such as Exception.args,\n        # OSError.errno\n        if issubclass(member, Exception):\n            instdict = member().__dict__\n        else:\n            raise TypeError\n    except TypeError:\n        pass\n    else:\n        for item_name, obj in instdict.items():\n            valnode = nodes.EmptyNode()\n            valnode.object = obj\n            valnode.parent = klass\n            valnode.lineno = 1\n            klass.instance_attrs[item_name] = [valnode]\n    return klass\n\n\ndef _build_from_function(node, name, member, module):\n    # verify this is not an imported function\n    try:\n        code = member.__code__\n    except AttributeError:\n        # Some implementations don't provide the code object,\n        # such as Jython.\n        code = None\n    filename = getattr(code, \"co_filename\", None)\n    if filename is None:\n        assert isinstance(member, object)\n        object_build_methoddescriptor(node, member, name)\n    elif filename != getattr(module, \"__file__\", None):\n        attach_dummy_node(node, name, member)\n    else:\n        object_build_function(node, member, name)\n\n\ndef _safe_has_attribute(obj, member):\n    try:\n        return hasattr(obj, member)\n    except Exception:  # pylint: disable=broad-except\n        return False\n\n\nclass InspectBuilder:\n    \"\"\"class for building nodes from living object\n\n    this is actually a really minimal representation, including only Module,\n    FunctionDef and ClassDef nodes and some others as guessed.\n    \"\"\"\n\n    def __init__(self, manager_instance=None):\n        self._manager = manager_instance or AstroidManager()\n        self._done = {}\n        self._module = None\n\n    def inspect_build(\n        self, module: types.ModuleType, modname: str = None, path: str = None\n    ) -> nodes.Module:\n        \"\"\"build astroid from a living module (i.e. using inspect)\n        this is used when there is no python source code available (either\n        because it's a built-in module or because the .py is not available)\n        \"\"\"\n        self._module = module\n        if modname is None:\n            modname = module.__name__\n        try:\n            node = build_module(modname, module.__doc__)\n        except AttributeError:\n            # in jython, java modules have no __doc__ (see #109562)\n            node = build_module(modname)\n        node.file = node.path = os.path.abspath(path) if path else path\n        node.name = modname\n        self._manager.cache_module(node)\n        node.package = hasattr(module, \"__path__\")\n        self._done = {}\n        self.object_build(node, module)\n        return node\n\n    def object_build(self, node, obj):\n        \"\"\"recursive method which create a partial ast from real objects\n        (only function, class, and method are handled)\n        \"\"\"\n        if obj in self._done:\n            return self._done[obj]\n        self._done[obj] = node\n        for name in dir(obj):\n            try:\n                with warnings.catch_warnings():\n                    warnings.filterwarnings(\"error\")\n                    member = getattr(obj, name)\n            except (AttributeError, DeprecationWarning):\n                # damned ExtensionClass.Base, I know you're there !\n                attach_dummy_node(node, name)\n                continue\n            if inspect.ismethod(member):\n                member = member.__func__\n            if inspect.isfunction(member):\n                _build_from_function(node, name, member, self._module)\n            elif inspect.isbuiltin(member):\n                if not _io_discrepancy(member) and self.imported_member(\n                    node, member, name\n                ):\n                    continue\n                object_build_methoddescriptor(node, member, name)\n            elif inspect.isclass(member):\n                if self.imported_member(node, member, name):\n                    continue\n                if member in self._done:\n                    class_node = self._done[member]\n                    if class_node not in node.locals.get(name, ()):\n                        node.add_local_node(class_node, name)\n                else:\n                    class_node = object_build_class(node, member, name)\n                    # recursion\n                    self.object_build(class_node, member)\n                if name == \"__class__\" and class_node.parent is None:\n                    class_node.parent = self._done[self._module]\n            elif inspect.ismethoddescriptor(member):\n                assert isinstance(member, object)\n                object_build_methoddescriptor(node, member, name)\n            elif inspect.isdatadescriptor(member):\n                assert isinstance(member, object)\n                object_build_datadescriptor(node, member, name)\n            elif isinstance(member, _CONSTANTS):\n                attach_const_node(node, name, member)\n            elif inspect.isroutine(member):\n                # This should be called for Jython, where some builtin\n                # methods aren't caught by isbuiltin branch.\n                _build_from_function(node, name, member, self._module)\n            elif _safe_has_attribute(member, \"__all__\"):\n                module = build_module(name)\n                _attach_local_node(node, module, name)\n                # recursion\n                self.object_build(module, member)\n            else:\n                # create an empty node so that the name is actually defined\n                attach_dummy_node(node, name, member)\n        return None\n\n    def imported_member(self, node, member, name):\n        \"\"\"verify this is not an imported class or handle it\"\"\"\n        # /!\\ some classes like ExtensionClass doesn't have a __module__\n        # attribute ! Also, this may trigger an exception on badly built module\n        # (see http://www.logilab.org/ticket/57299 for instance)\n        try:\n            modname = getattr(member, \"__module__\", None)\n        except TypeError:\n            modname = None\n        if modname is None:\n            if name in {\"__new__\", \"__subclasshook__\"}:\n                # Python 2.5.1 (r251:54863, Sep  1 2010, 22:03:14)\n                # >>> print object.__new__.__module__\n                # None\n                modname = builtins.__name__\n            else:\n                attach_dummy_node(node, name, member)\n                return True\n\n        real_name = {\"gtk\": \"gtk_gtk\", \"_io\": \"io\"}.get(modname, modname)\n\n        if real_name != self._module.__name__:\n            # check if it sounds valid and then add an import node, else use a\n            # dummy node\n            try:\n                getattr(sys.modules[modname], name)\n            except (KeyError, AttributeError):\n                attach_dummy_node(node, name, member)\n            else:\n                attach_import_node(node, modname, name)\n            return True\n        return False\n\n\n# astroid bootstrapping ######################################################\n\n_CONST_PROXY = {}\n\n\ndef _set_proxied(const):\n    # TODO : find a nicer way to handle this situation;\n    return _CONST_PROXY[const.value.__class__]\n\n\ndef _astroid_bootstrapping():\n    \"\"\"astroid bootstrapping the builtins module\"\"\"\n    # this boot strapping is necessary since we need the Const nodes to\n    # inspect_build builtins, and then we can proxy Const\n    builder = InspectBuilder()\n    astroid_builtin = builder.inspect_build(builtins)\n\n    for cls, node_cls in node_classes.CONST_CLS.items():\n        if cls is TYPE_NONE:\n            proxy = build_class(\"NoneType\")\n            proxy.parent = astroid_builtin\n        elif cls is TYPE_NOTIMPLEMENTED:\n            proxy = build_class(\"NotImplementedType\")\n            proxy.parent = astroid_builtin\n        elif cls is TYPE_ELLIPSIS:\n            proxy = build_class(\"Ellipsis\")\n            proxy.parent = astroid_builtin\n        else:\n            proxy = astroid_builtin.getattr(cls.__name__)[0]\n        if cls in (dict, list, set, tuple):\n            node_cls._proxied = proxy\n        else:\n            _CONST_PROXY[cls] = proxy\n\n    # Set the builtin module as parent for some builtins.\n    nodes.Const._proxied = property(_set_proxied)\n\n    _GeneratorType = nodes.ClassDef(\n        types.GeneratorType.__name__, types.GeneratorType.__doc__\n    )\n    _GeneratorType.parent = astroid_builtin\n    bases.Generator._proxied = _GeneratorType\n    builder.object_build(bases.Generator._proxied, types.GeneratorType)\n\n    if hasattr(types, \"AsyncGeneratorType\"):\n        _AsyncGeneratorType = nodes.ClassDef(\n            types.AsyncGeneratorType.__name__, types.AsyncGeneratorType.__doc__\n        )\n        _AsyncGeneratorType.parent = astroid_builtin\n        bases.AsyncGenerator._proxied = _AsyncGeneratorType\n        builder.object_build(bases.AsyncGenerator._proxied, types.AsyncGeneratorType)\n    builtin_types = (\n        types.GetSetDescriptorType,\n        types.GeneratorType,\n        types.MemberDescriptorType,\n        TYPE_NONE,\n        TYPE_NOTIMPLEMENTED,\n        types.FunctionType,\n        types.MethodType,\n        types.BuiltinFunctionType,\n        types.ModuleType,\n        types.TracebackType,\n    )\n    for _type in builtin_types:\n        if _type.__name__ not in astroid_builtin:\n            cls = nodes.ClassDef(_type.__name__, _type.__doc__)\n            cls.parent = astroid_builtin\n            builder.object_build(cls, _type)\n            astroid_builtin[_type.__name__] = cls\n\n\n_astroid_bootstrapping()\n","header":{"file":{"path":"astroid/raw_building.py"},"misc_line":null},"index_line":null,"is_binary_file":false,"binary_line":null,"minus_file":{"path":"a/astroid/raw_building.py"},"plus_file":{"path":"b/astroid/raw_building.py"},"hunks":[{"descriptor":{"old_range":{"start":10,"length":11},"new_range":{"start":10,"length":14},"section":""},"line_group":{"all_lines":[{"content":"","type":"context"},{"content":"import builtins","type":"context"},{"content":"import inspect","type":"context"},{"content":"import io","type":"added"},{"content":"import logging","type":"added"},{"content":"import os","type":"context"},{"content":"import sys","type":"context"},{"content":"import types","type":"context"},{"content":"import warnings","type":"context"},{"content":"from collections.abc import Iterable","type":"context"},{"content":"from contextlib import redirect_stderr, redirect_stdout","type":"added"},{"content":"from typing import Any, Union","type":"context"},{"content":"","type":"context"},{"content":"from astroid import bases, nodes","type":"context"}]},"modified_entities":[],"added_entities":[],"deleted_entities":[]},{"descriptor":{"old_range":{"start":22,"length":6},"new_range":{"start":25,"length":9},"section":""},"line_group":{"all_lines":[{"content":"from astroid.manager import AstroidManager","type":"context"},{"content":"from astroid.nodes import node_classes","type":"context"},{"content":"","type":"context"},{"content":"logger = logging.getLogger(__name__)","type":"added"},{"content":"","type":"added"},{"content":"","type":"added"},{"content":"_FunctionTypes = Union[","type":"context"},{"content":"    types.FunctionType,","type":"context"},{"content":"    types.MethodType,","type":"context"}]},"modified_entities":[],"added_entities":[],"deleted_entities":[]},{"descriptor":{"old_range":{"start":471,"length":7},"new_range":{"start":477,"length":26},"section":"def imported_member(self, node, member, name: str) -> bool:"},"line_group":{"all_lines":[{"content":"            # check if it sounds valid and then add an import node, else use a","type":"context"},{"content":"            # dummy node","type":"context"},{"content":"            try:","type":"context"},{"content":"                getattr(sys.modules[modname], name)","type":"deleted"},{"content":"                with redirect_stderr(io.StringIO()) as stderr, redirect_stdout(","type":"added"},{"content":"                    io.StringIO()","type":"added"},{"content":"                ) as stdout:","type":"added"},{"content":"                    getattr(sys.modules[modname], name)","type":"added"},{"content":"                    stderr_value = stderr.getvalue()","type":"added"},{"content":"                    if stderr_value:","type":"added"},{"content":"                        logger.error(","type":"added"},{"content":"                            \"Captured stderr while getting %s from %s:\\n%s\",","type":"added"},{"content":"                            name,","type":"added"},{"content":"                            sys.modules[modname],","type":"added"},{"content":"                            stderr_value,","type":"added"},{"content":"                        )","type":"added"},{"content":"                    stdout_value = stdout.getvalue()","type":"added"},{"content":"                    if stdout_value:","type":"added"},{"content":"                        logger.info(","type":"added"},{"content":"                            \"Captured stdout while getting %s from %s:\\n%s\",","type":"added"},{"content":"                            name,","type":"added"},{"content":"                            sys.modules[modname],","type":"added"},{"content":"                            stdout_value,","type":"added"},{"content":"                        )","type":"added"},{"content":"            except (KeyError, AttributeError):","type":"context"},{"content":"                attach_dummy_node(node, name, member)","type":"context"},{"content":"            else:","type":"context"},{"content":"","type":"context"}]},"modified_entities":[],"added_entities":[],"deleted_entities":[]}]}],"old_commit_hash":"0c9ab0fe56703fa83c73e514a1020d398d23fa7f","new_commit_hash":"9b6ebb18f75f49da85fd3543b71ed532911b1ede","commit_message":"Update ChangeLog","commit_date":"2021-11-21T17:53:21+01:00","metadata":{}}