Skip to content

[Bugfix] Fix wrong imports in examples #1241

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

Merged
merged 3 commits into from
Jul 25, 2025
Merged

[Bugfix] Fix wrong imports in examples #1241

merged 3 commits into from
Jul 25, 2025

Conversation

mdagost
Copy link
Contributor

@mdagost mdagost commented Jul 24, 2025

The current script gives

Traceback (most recent call last):
  File "/Users/xmxd289/code/openai-agents-python/examples/reasoning_content/main.py", line 19, in <module>
    from agents.types import ResponseOutputRefusal, ResponseOutputText  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'agents.types'

because it should be

from openai.types.responses import ResponseOutputRefusal, ResponseOutputText

rather than

from agents.types import ResponseOutputRefusal, ResponseOutputText

@seratch seratch added bug Something isn't working documentation Improvements or additions to documentation labels Jul 25, 2025
@seratch seratch changed the title [Bugfix] Fix wrong import. [Bugfix] Fix wrong imports in examples Jul 25, 2025
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you resolve the lint error?

uv run ruff check
examples/reasoning_content/main.py:12:1: I001 [*] Import block is un-sorted or un-formatted
   |
10 |   """
11 |
12 | / import asyncio
13 | | import os
14 | | from typing import Any, cast
15 | |
16 | | from agents import ModelSettings
17 | | from agents.models.interface import ModelTracing
18 | | from agents.models.openai_provider import OpenAIProvider
19 | | from openai.types.responses import ResponseOutputRefusal, ResponseOutputText  # type: ignore
20 | |
   | |__^ I001
21 |   MODEL_NAME = os.getenv("EXAMPLE_MODEL_NAME") or "deepseek-reasoner"
   |
   = help: Organize imports

Found 1 error.
[*] 1 fixable with the `--fix` option.
make: *** [Makefile:16: lint] Error 1
Error: Process completed with exit code 2.

Also, the type: ignore comment may no longer be necessary

Michelangelo D'Agostino and others added 2 commits July 24, 2025 19:30
@mdagost
Copy link
Contributor Author

mdagost commented Jul 25, 2025

Yep! There you go!

@seratch seratch enabled auto-merge (squash) July 25, 2025 00:34
@seratch seratch merged commit d052c1f into openai:main Jul 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants