Skip to content

perf: skip LLM imports when MYCLI_LLM_OFF is set#1918

Merged
rolandwalker merged 1 commit into
dbcli:mainfrom
Dragonliu2018:lzl/perf/skip-llm-imports-when-llm-off
Jun 6, 2026
Merged

perf: skip LLM imports when MYCLI_LLM_OFF is set#1918
rolandwalker merged 1 commit into
dbcli:mainfrom
Dragonliu2018:lzl/perf/skip-llm-imports-when-llm-off

Conversation

@Dragonliu2018
Copy link
Copy Markdown
Contributor

@Dragonliu2018 Dragonliu2018 commented Jun 6, 2026

Description

special/__init__.py unconditionally imported LLM symbols on every startup, pulling in the entire openai package even when LLM features are unused. llm.py and main.py already guarded their imports with MYCLI_LLM_OFF, but __init__.py bypassed that protection.

This PR brings __init__.py in line with the rest: when MYCLI_LLM_OFF=1, LLM imports are skipped and lightweight stubs are provided instead, reducing startup time.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

Comment thread mycli/packages/special/__init__.py Outdated
@@ -1,3 +1,5 @@
import os as _os
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is as _os needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's unnecessary. Simplified to import os. Thanks!

@Dragonliu2018 Dragonliu2018 force-pushed the lzl/perf/skip-llm-imports-when-llm-off branch from a336a0e to c1b31bd Compare June 6, 2026 12:06
@rolandwalker
Copy link
Copy Markdown
Contributor

Great catch, thank you!

@rolandwalker rolandwalker merged commit a467d0a into dbcli:main Jun 6, 2026
11 checks passed
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