"""
Mixed use of pydantic with mongoengine that raises
astroid.exceptions.InferenceError: StopIteration raised without any error information.
"""
from mongoengine import Document
from pydantic import BaseModel
class Users(Document): # pylint: disable=too-few-public-methods
"""A mongoengine document model"""
class UsersPydantic(BaseModel): # pylint: disable=too-few-public-methods
"""Pydantic Base Model"""
type_: Users
def get_value(self) -> Users:
"""get some document"""
return self.type_.objects()[0]
class Config: # pylint: disable=too-few-public-methods
"""update meta details"""
arbitrary_types_allowed = True
pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
File "my_repo/virtuals/lib/python3.10/site-packages/astroid/decorators.py", line 140, in raise_if_nothing_inferred
yield next(generator)
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 790, in _lint_file
check_astroid_module(module)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 1060, in check_astroid_module
retval = self._check_astroid_module(
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 1110, in _check_astroid_module
walker.walk(node)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
[Previous line repeated 3 more times]
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 90, in walk
callback(astroid)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint_plugin_utils/__init__.py", line 60, in __call__
self.augmentation_func(Chain(self.old_method, node), node)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint_plugin_utils/__init__.py", line 117, in __call__
if self.test_func(node):
File "my_repo/virtuals/lib/python3.10/site-packages/pylint_mongoengine/utils.py", line 115, in node_is_default_qs
for cls in base_cls.inferred():
File "my_repo/virtuals/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 611, in inferred
return list(self.infer())
File "my_repo/virtuals/lib/python3.10/site-packages/astroid/nodes/node_ng.py", line 169, in infer
yield from self._infer(context=context, **kwargs)
File "my_repo/virtuals/lib/python3.10/site-packages/astroid/decorators.py", line 146, in raise_if_nothing_inferred
raise InferenceError(
astroid.exceptions.InferenceError: StopIteration raised without any error information.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 755, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "my_repo/virtuals/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 792, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Re-reporting from Pylint issue
Bug description
Configuration
Command used
Pylint output
Expected behavior
Pylint exits peacefully!
Pylint version
OS / Environment
No response
Additional dependencies
pylint-mongoengine==0.4.0 pylint-plugin-utils==0.7 pylint-pydantic==0.1.4 pydantic==1.10.4 mongoengine==0.25.0