Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions eval_protocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@
try:
from .proxy import create_app, AuthProvider, AccountInfo
except ImportError:
create_app = None
AuthProvider = None
AccountInfo = None

def _proxy_import_error(*args, **kwargs):
raise ImportError(
"Proxy functionality requires additional dependencies. "
"Please install with: pip install eval-protocol[proxy]"
)

create_app = _proxy_import_error
AuthProvider = _proxy_import_error
AccountInfo = _proxy_import_error
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Delayed ImportError in Proxy Assignment

Assigning the _proxy_import_error function to AuthProvider and AccountInfo (intended as classes) means type annotations and isinstance checks won't immediately raise an ImportError. The error only appears when the function is called, which delays feedback compared to the previous None assignment.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@xzrderek this is how it is recommended to solve this:

try:
    from real_module import AuthProvider
except ImportError:
    class AuthProvider:
        def __init__(self, *args, **kwargs):
            raise ImportError(
                "Proxy functionality requires additional dependencies. "
                "Please install with: pip install eval-protocol[proxy]"
            )

Code that expects a class, uses type hints or isinstance detection, or needs to inspect Class attributes will work as normal, right up until someone tries to “use” the missing feature. That’s when it fails loudly and clearly.

Comment thread
xzrderek marked this conversation as resolved.
Outdated


warnings.filterwarnings("default", category=DeprecationWarning, module="eval_protocol")
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ langgraph_tools = [
"langchain-fireworks>=0.3.0",
]

proxy = [
"redis>=5.0.0",
"langfuse>=2.0.0",
"uuid6>=2025.0.0",
]

[project.scripts]
fireworks-reward = "eval_protocol.cli:main"
eval-protocol = "eval_protocol.cli:main"
Expand Down
31 changes: 30 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading