Skip to content

Minor fixes#275

Closed
voorhs wants to merge 5 commits intofeat/lazy-import-heavy-dependenciesfrom
minor-fixes
Closed

Minor fixes#275
voorhs wants to merge 5 commits intofeat/lazy-import-heavy-dependenciesfrom
minor-fixes

Conversation

@voorhs
Copy link
Collaborator

@voorhs voorhs commented Feb 19, 2026

No description provided.

@voorhs voorhs requested a review from Samoed February 19, 2026 18:56
def _get_client(self) -> openai.OpenAI:
"""Get or create OpenAI client instance."""
import openai
openai = require("openai", "openai")
Copy link
Member

Choose a reason for hiding this comment

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

Это в init уже проверяется. Мне кажется что можно просто импортировать

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

без этих штук ruff ругается что не установлен openai + так консистентнее, потому что в большинстве случаев именно через require импорт идет

Copy link
Member

Choose a reason for hiding this comment

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

Я думаю ты про mypy и такой способ не позволяет валидировать типизацию

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. окей, это не ruff, это какой-то другой линтер
image
  1. хорошо это кажется действительно, тогда я еще подумаю - потому что тогда мы должны отказаться от использования require во всех местах где только можно

Copy link
Collaborator Author

@voorhs voorhs Feb 20, 2026

Choose a reason for hiding this comment

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

тогда мне кажется что стоит отказаться от использования require для импорта - стоит его использовать только чтобы выводить информационное сообщение об отсутствии необходимой зависимости

импорты опциональных зависимостей стоит делать только внутри TYPE_CHECKING секции и внутри функций и методов классов. первое обеспечит тайпчекинг, второе позволит лениво подгружать опциональные зависимости

а на эти проблемы reportMissingImports придется забить

что думаешь?

Copy link
Member

@Samoed Samoed Feb 20, 2026

Choose a reason for hiding this comment

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

Да, согласен. В mteb так и делаем

@voorhs voorhs closed this Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants