Skip to content

ValueError in zero_shot_object_detection.md doctest on Python 3.13 #45657

@AnkitAhlawat7742

Description

@AnkitAhlawat7742

While running the test suite on Python 3.13.7, pytest fails to collect tests due to a malformed doctest in docs/source/en/tasks/zero_shot_object_detection.md.
Environment:

Python: 3.13.7
Platform: macOS (darwin)
transformers: main branch

Error:
ValueError: line 172 of the docstring for zero_shot_object_detection.md
lacks blank after ...: '...)[0]'

(py313_env) ankitahlawat@AnkitAhlawats-MacBook-Pro transformers % pytest .
================================================================================================ test session starts =================================================================================================
platform darwin -- Python 3.13.7, pytest-8.4.2, pluggy-1.6.0
Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type>
rootdir: /Users/ankitahlawat/Desktop/AnkitAhlawat/opensource_contribution/transformers
configfile: pyproject.toml
plugins: anyio-4.12.1, xdist-3.8.0, random-order-1.2.0, timeout-2.4.0, order-1.4.0, rerunfailures-15.1, asyncio-1.3.0, env-1.2.0, rich-0.2.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collected 130641 items / 1 error

======================================================================================================= ERRORS =======================================================================================================
________________________________________________________________________ ERROR collecting docs/source/en/tasks/zero_shot_object_detection.md _________________________________________________________________________
/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/doctest.py:703: in get_doctest
    return DocTest(self.get_examples(string, name), globs,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/doctest.py:717: in get_examples
    return [x for x in self.parse(string, name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^
src/transformers/testing_utils.py:2883: in parse
    return super().parse(string, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/doctest.py:679: in parse
    self._parse_example(m, name, lineno)
/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/doctest.py:737: in _parse_example
    self._check_prompt_blank(source_lines, indent, name, lineno)
/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/doctest.py:821: in _check_prompt_blank
    raise ValueError('line %r of the docstring for %s '
E   ValueError: line 172 of the docstring for zero_shot_object_detection.md lacks blank after ...: '...)[0]'

can be fix like

@@ -169,7 +169,7 @@ boxes have the correct coordinates relative to the original image:

 >>> results = processor.post_process_grounded_object_detection(
 ...    outputs, threshold=0.50, target_sizes=[(image.height, image.width)], text_labels=text_labels,
-...)[0]
+... )[0]

 >>> draw = ImageDraw.Draw(image)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions