Skip to content

Commit

Permalink
Infinity: Use a runtime type hint for engine
Browse files Browse the repository at this point in the history
Remove the antipattern of the conditional type for the Async engine
and use string-based type inference.

Signed-off-by: kingbri <[email protected]>
  • Loading branch information
kingbri1 committed Nov 22, 2024
1 parent 242ff4f commit aa4ccd0
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions backends/infinity/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ class InfinityContainer:
model_is_loading: bool = False
model_loaded: bool = False

# Conditionally set the type hint based on importablity
# TODO: Clean this up
if dependencies.extras:
engine: Optional[AsyncEmbeddingEngine] = None
else:
engine = None
# Use a runtime type hint here
engine: Optional["AsyncEmbeddingEngine"] = None

def __init__(self, model_directory: pathlib.Path):
self.model_dir = model_directory
Expand Down

0 comments on commit aa4ccd0

Please sign in to comment.