Skip to content

Commit

Permalink
Apply a small fix suggested by linter: Ruff E721
Browse files Browse the repository at this point in the history
Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
  • Loading branch information
yvan-sraka committed Jan 9, 2025
1 parent eaa77b5 commit 6286db7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions outlines/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Any, Callable, Dict, Optional, Type, cast

import jinja2
from pydantic import BaseModel
import pydantic


@dataclass
Expand Down Expand Up @@ -253,10 +253,10 @@ def get_schema_dict(model: Dict):
return json.dumps(model, indent=2)


@get_schema.register(type(BaseModel))
def get_schema_pydantic(model: Type[BaseModel]):
@get_schema.register(type(pydantic.BaseModel))
def get_schema_pydantic(model: Type[pydantic.BaseModel]):
"""Return the schema of a Pydantic model."""
if not type(model) == type(BaseModel):
if not isinstance(model, type(pydantic.BaseModel)):
raise TypeError("The `schema` filter only applies to Pydantic models.")

if hasattr(model, "model_json_schema"):
Expand Down

0 comments on commit 6286db7

Please sign in to comment.