English | 日本語

English {#english}
VS Code extension that automatically formats and generates __all__ in Python __init__.py files based on import statements.
Features
- Automated
__all__ Generation: Reads import and from ... import ... statements in __init__.py and generates/updates __all__.
- Duplicate Removal & Sorting: Automatically deduplicates imported names and sorts them alphabetically.
- ContextMenu Support: Easily execute from the right-click context menu in the Explorer or Editor on
__init__.py files.
- Internationalization (i18n): Fully supports English and Japanese UI/messages.
Usage
- Open a Python
__init__.py file in the editor or select it in the Explorer.
- Right-click on the file or inside the editor.
- Select "Format all in init.py" from the context menu.
(Alternatively, run the
Format __all__ in __init__.py command from the Command Palette Ctrl+Shift+P / Cmd+Shift+P)
Example
Before
from .rm import safe_remove
from .bin import write_bytes
from .comp import cmp_is_equal_fast
from .hash import get_file_hash, comp_file_hash
from .rm import safe_remove
from .bin import write_bytes
from .comp import cmp_is_equal_fast
from .hash import get_file_hash, comp_file_hash
__all__ = [
'cmp_is_equal_fast',
'comp_file_hash',
'get_file_hash',
'safe_remove',
'write_bytes',
]
Requirements
- Visual Studio Code v1.85.0 or higher.
日本語 {#japanese}
Pythonの __init__.py 内のインポート記述を解析し、__all__ リストを自動生成・整形するVS Code拡張機能です。
主な機能
__all__ の自動生成: __init__.py 内の import および from ... import ... 文を読み込み、アルファベット順にソートされた __all__ を自動生成・更新します。
- 重複除去: インポートされた名前の重複を自動的に排除します。
- コンテキストメニュー対応: エクスプローラーやエディター上で
__init__.py を右クリックして簡単に実行できます。
- 多言語対応: 日本語および英語の表示に対応しています。
使い方
- エディターで
__init__.py を開くか、エクスプローラー上で対象の __init__.py を選択します。
- エディター内またはエクスプローラー上で右クリックします。
- メニューから 「init.py の all を整形」 を選択します。
(コマンドパレット
Ctrl+Shift+P / Cmd+Shift+P から __init__.py の __all__ を整形 を実行することも可能です)
実行例
実行前
from .rm import safe_remove
from .bin import write_bytes
from .comp import cmp_is_equal_fast
from .hash import get_file_hash, comp_file_hash
整形実行後
from .rm import safe_remove
from .bin import write_bytes
from .comp import cmp_is_equal_fast
from .hash import get_file_hash, comp_file_hash
__all__ = [
'cmp_is_equal_fast',
'comp_file_hash',
'get_file_hash',
'safe_remove',
'write_bytes',
]
License
Apache License 2.0