pylint
pylint copied to clipboard
Crash `TypeError: 'UninferableBase' object is not iterable` - [astroid-error]
Bug description
When parsing the following a.py:
"""
ASGI config for any ft_core based project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
"""
import multiprocessing
import os
from django import setup
from django.core.asgi import get_asgi_application as django_asgi_application
from .protocol_router import Router
def get_asgi_application():
# from ft_core.multiprocessing.functions import on_exit_hook, on_starting_hook
from ft_core.settings.functions import get_env
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
setup(set_prefix=False)
django_application = django_asgi_application()
from django.conf import settings
force_forkserver = get_env("FORCE_FORKSERVER", default=False, as_bool=True)
if os.name != "nt" and (not settings.DEBUG or force_forkserver):
multiprocessing.set_start_method("forkserver")
if settings.DEBUG and not force_forkserver:
# on_starting_hook(None)
# atexit.register(lambda: on_exit_hook(None))
pass
from ft_core.graphql.schema import get_schema
return Router(
schema=get_schema(),
django_application=django_application,
graphql_ide="graphiql" if settings.DEBUG else None,
multipart_uploads_enabled=False,
)
Command used
pylint a.py
Pylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\checkers\imports.py", line 1012, in _get_imported_module
return importnode.do_import_module(modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\nodes\_base_nodes.py", line 168, in do_import_module
return mymodule.import_module(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\nodes\scoped_nodes\scoped_nodes.py", line 462, in import_module
return AstroidManager().ast_from_module_name(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\manager.py", line 276, in ast_from_module_name
return self.ast_from_file(found_spec.location, modname, fallback=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\manager.py", line 166, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\builder.py", line 145, in file_build
return self._post_build(module, builder, encoding)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\builder.py", line 173, in _post_build
module = self._manager.visit_transforms(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\manager.py", line 127, in visit_transforms
return self._transform.visit(node)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\transforms.py", line 158, in visit
return self._visit(node)
^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\transforms.py", line 85, in _visit
return self._transform(node)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\transforms.py", line 67, in _transform
ret = transform_func(node)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\brain\helpers.py", line 17, in transform
extension_module = get_extension_mod()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\astroid\brain\brain_multiprocessing.py", line 38, in _multiprocessing_transform
for key, value in node.locals.items():
TypeError: 'UninferableBase' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\lint\pylinter.py", line 788, in _lint_file
check_astroid_module(module)
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\lint\pylinter.py", line 1020, in check_astroid_module
retval = self._check_astroid_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\lint\pylinter.py", line 1072, in _check_astroid_module
walker.walk(node)
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
self.walk(child)
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\utils\ast_walker.py", line 87, in walk
callback(astroid)
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\checkers\imports.py", line 540, in visit_import
imported_module = self._get_imported_module(node, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\checkers\imports.py", line 1037, in _get_imported_module
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\lint\pylinter.py", line 752, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "C:\Users\amine\env\ft_core.new\Lib\site-packages\pylint\lint\pylinter.py", line 790, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
No crash.
Pylint version
pylint 3.3.6
astroid 3.3.9
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]
OS / Environment
win32 (Windows)