Skip to content

back to SWE-Agent summary

SWE-Agent: sphinx

Failed to run pytests for test tests

ImportError while loading conftest '/testbed/tests/conftest.py'.
tests/conftest.py:15: in <module>
    import sphinx.pycode
sphinx/pycode/__init__.py:11: in <module>
    from sphinx.pycode.parser import Parser
sphinx/pycode/parser.py:15: in <module>
    from sphinx.pycode.ast import unparse as ast_unparse
sphinx/pycode/ast.py:11: in <module>
    class _UnparseVisitor(ast.NodeVisitor):
sphinx/pycode/ast.py:16: in _UnparseVisitor
    locals()[f'visit_{_op.__name__}'] = _visit_op
E   NameError: name '_visit_op' is not defined

Patch diff

diff --git a/sphinx/config.py b/sphinx/config.py
index 60831c8f4..7a081b946 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -36,7 +36,23 @@ class ConfigValue(NamedTuple):

 def is_serializable(obj: object, *, _seen: frozenset[int]=frozenset()) -> bool:
     """Check if an object is serializable or not."""
-    pass
+    obj_id = id(obj)
+    if obj_id in _seen:
+        return True
+    new_seen = _seen | {obj_id}
+    if isinstance(obj, UNSERIALIZABLE_TYPES):
+        return False
+    elif isinstance(obj, (str, int, float, bool, type(None))):
+        return True
+    elif isinstance(obj, (list, tuple)):
+        return all(is_serializable(item, _seen=new_seen) for item in obj)
+    elif isinstance(obj, dict):
+        return all(is_serializable(key, _seen=new_seen) and is_serializable(value, _seen=new_seen) 
+                   for key, value in obj.items())
+    elif hasattr(obj, '__dict__'):
+        return is_serializable(obj.__dict__, _seen=new_seen)
+    else:
+        return True

 class ENUM:
     """Represents the candidates which a config value should be one of.
@@ -296,4 +312,4 @@ def check_root_doc(app: Sphinx, env: BuildEnvironment, added: Set[str], changed:
     """Adjust root_doc to 'contents' to support an old project which does not have
     any root_doc setting.
     """
-    pass
\ No newline at end of file
+    pass