-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Cannot import Astroid with schemathesis 3.19.6. #11053
Comments
With the help of some t.py:3: in <module>
from astroid.nodes import Import
.venv/lib/python3.11/site-packages/astroid/__init__.py:46: in <module>
from astroid import inference, raw_building
.venv/lib/python3.11/site-packages/astroid/inference.py:17: in <module>
from astroid import bases, constraint, decorators, helpers, nodes, protocols, util
.venv/lib/python3.11/site-packages/astroid/helpers.py:11: in <module>
from astroid import bases, manager, nodes, objects, raw_building, util
.venv/lib/python3.11/site-packages/astroid/raw_building.py:643: in <module>
_astroid_bootstrapping()
.venv/lib/python3.11/site-packages/astroid/raw_building.py:544: in _astroid_bootstrapping
astroid_builtin = builder.inspect_build(builtins)
.venv/lib/python3.11/site-packages/astroid/raw_building.py:404: in inspect_build
self.object_build(node, module)
.venv/lib/python3.11/site-packages/astroid/raw_building.py:455: in object_build
attach_const_node(node, name, member)
.venv/lib/python3.11/site-packages/astroid/raw_building.py:78: in attach_const_node
_attach_local_node(node, nodes.const_factory(value), name)
.venv/lib/python3.11/site-packages/astroid/nodes/node_classes.py:5644: in const_factory
instance.postinit(_create_dict_items(value, instance))
.venv/lib/python3.11/site-packages/astroid/nodes/node_classes.py:5618: in _create_dict_items
value_node = const_factory(value)
.venv/lib/python3.11/site-packages/astroid/nodes/node_classes.py:5644: in const_factory
instance.postinit(_create_dict_items(value, instance))
.venv/lib/python3.11/site-packages/astroid/nodes/node_classes.py:5618: in _create_dict_items
value_node = const_factory(value)
.venv/lib/python3.11/site-packages/astroid/nodes/node_classes.py:5644: in const_factory
instance.postinit(_create_dict_items(value, instance))
.venv/lib/python3.11/site-packages/astroid/nodes/node_classes.py:5618: in _create_dict_items
value_node = const_factory(value) And this happens because somehow, With your example and pytest:
outside of it, when running with Python directly:
When simply running a module containing That seems to come from schemathesis somehow: >>> hasattr(__builtins__, "__builtins__")
False
>>> import schemathesis
>>> hasattr(__builtins__, "__builtins__")
True so to summarize:
I have no answers, but many questions. |
It gets weirder! The "turning print(type(__builtins__)) This happens: $ python3 t.py
<class 'module'>
$ python3 -m pdb -c cont -c quit t.py
<class 'dict'>
The program finished and will be restarted And the "adding This example: from dataclasses import dataclass
print(type(__builtins__))
print(hasattr(__builtins__, "__builtins__"))
@dataclass
class Bla(Exception):
__module__ = "builtins"
print(type(__builtins__))
print(hasattr(__builtins__, "__builtins__"))
import astroid.nodes results in: <class 'module'>
False
<class 'module'>
True followed by the same endless recursion (even if Traceback (most recent call last):
File "/home/florian/tmp/blabla/dc.py", line 14, in <module>
import astroid.nodes
File "/usr/lib/python3.11/site-packages/astroid/__init__.py", line 46, in <module>
from astroid import inference, raw_building
File "/usr/lib/python3.11/site-packages/astroid/inference.py", line 17, in <module>
from astroid import bases, constraint, decorators, helpers, nodes, protocols, util
File "/usr/lib/python3.11/site-packages/astroid/helpers.py", line 11, in <module>
from astroid import bases, manager, nodes, objects, raw_building, util
File "/usr/lib/python3.11/site-packages/astroid/raw_building.py", line 643, in <module>
_astroid_bootstrapping()
File "/usr/lib/python3.11/site-packages/astroid/raw_building.py", line 544, in _astroid_bootstrapping
astroid_builtin = builder.inspect_build(builtins)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/astroid/raw_building.py", line 404, in inspect_build
self.object_build(node, module)
File "/usr/lib/python3.11/site-packages/astroid/raw_building.py", line 455, in object_build
attach_const_node(node, name, member)
File "/usr/lib/python3.11/site-packages/astroid/raw_building.py", line 78, in attach_const_node
_attach_local_node(node, nodes.const_factory(value), name)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/astroid/nodes/node_classes.py", line 5641, in const_factory
instance.postinit(_create_dict_items(value, instance))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/astroid/nodes/node_classes.py", line 5615, in _create_dict_items
value_node = const_factory(value)
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/astroid/nodes/node_classes.py", line 5641, in const_factory
instance.postinit(_create_dict_items(value, instance))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/astroid/nodes/node_classes.py", line 5615, in _create_dict_items
value_node = const_factory(value)
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/astroid/nodes/node_classes.py", line 5641, in const_factory
instance.postinit(_create_dict_items(value, instance))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I don't know what to make of this. Two stdlib bugs (?) for the price of one? In any case, pytest seems to be out of the picture. Going to comment in the other threads. |
Describe the bug
When I start a pytest session the astroid package enters an infinite loop when it is imported.
To Reproduce
I prepared a pipenv file that creates an environment to reproduce the issues.
Once you downloaded all files run
make .venv
run-pipenv run python -m pytest t.py --pdb
This will drop you in a debugger session at the place where astroid is stuck in a loop. With version 3.19.0 everything still works.
Expected behavior
Adding schemathesis as a dependency has no impact if I can import astroid in a pytest environment or not.
Environment (please complete the following information):
Additional context
I'm not sure what the root cause is so I will also open tickets for this with schemathesis and astroid.
The text was updated successfully, but these errors were encountered: