theroyallab/tabbyAPI

[REQUEST] Defered Type Hints & Type_checking paradigm

Closed this issue · 1 comments

Problem

I saw the following pattern in your codebase!

Use: - https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING TYPE_CHECKING variable to only import type hints when needed.
And

defered type hints as forward reference: https://stackoverflow.com/questions/51629105/python-type-hint-given-as-a-string

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

Solution

Above

Alternatives

No response

Explanation

Just fyi, send from mobile

Examples

No response

Additional context

No response

Acknowledgements

  • I have looked for similar requests before submitting this one.
  • I understand that the developers have lives and my issue will be answered when possible.
  • I understand the developers of this program are human, and I will make my requests politely.

Fixed in aa4ccd0

Not sure what StackOverflow means that runtime typing via strings is deprecated, but I'll keep it until it's gone.