Skip to content

Commit 0ab7616

Browse files
jfcherngdeathaxe
and
deathaxe
authored
refactor: use native types and f-string (#2459)
* refactor: use native types and f-string Signed-off-by: Jack Cherng <[email protected]> * refactor: remove unused import Signed-off-by: Jack Cherng <[email protected]> * fix: make flake8 happier Signed-off-by: Jack Cherng <[email protected]> * refactor: naive __all__ for boot.py Signed-off-by: Jack Cherng <[email protected]> * Update boot.py Co-authored-by: deathaxe <[email protected]> * chore: remove unused imports Signed-off-by: Jack Cherng <[email protected]> * revert: rollback to str.format for long lines (>120 chars) Signed-off-by: Jack Cherng <[email protected]> * revert: rollback intentional code alignment Signed-off-by: Jack Cherng <[email protected]> --------- Signed-off-by: Jack Cherng <[email protected]> Co-authored-by: deathaxe <[email protected]>
1 parent a3867f4 commit 0ab7616

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1386
-1343
lines changed

boot.py

+81-7
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
from .plugin.configuration import LspDisableLanguageServerInProjectCommand
1818
from .plugin.configuration import LspEnableLanguageServerGloballyCommand
1919
from .plugin.configuration import LspEnableLanguageServerInProjectCommand
20-
from .plugin.core.collections import DottedDict
2120
from .plugin.core.css import load as load_css
2221
from .plugin.core.open import opening_files
2322
from .plugin.core.panels import PanelName
24-
from .plugin.core.protocol import Error
2523
from .plugin.core.registry import LspNextDiagnosticCommand
2624
from .plugin.core.registry import LspOpenLocationCommand
2725
from .plugin.core.registry import LspPrevDiagnosticCommand
@@ -86,10 +84,86 @@
8684
from .plugin.tooling import LspOnDoubleClickCommand
8785
from .plugin.tooling import LspParseVscodePackageJson
8886
from .plugin.tooling import LspTroubleshootServerCommand
89-
from typing import Any, Dict, List, Optional, Type
87+
from typing import Any
9088

89+
__all__ = (
90+
"DocumentSyncListener",
91+
"Listener",
92+
"LspApplyDocumentEditCommand",
93+
"LspApplyWorkspaceEditCommand",
94+
"LspCallHierarchyCommand",
95+
"LspClearLogPanelCommand",
96+
"LspClearPanelCommand",
97+
"LspCodeActionsCommand",
98+
"LspCodeLensCommand",
99+
"LspCollapseTreeItemCommand",
100+
"LspColorPresentationCommand",
101+
"LspCommitCompletionWithOppositeInsertMode",
102+
"LspCopyToClipboardFromBase64Command",
103+
"LspDisableLanguageServerGloballyCommand",
104+
"LspDisableLanguageServerInProjectCommand",
105+
"LspDocumentSymbolsCommand",
106+
"LspDumpBufferCapabilities",
107+
"LspDumpWindowConfigs",
108+
"LspEnableLanguageServerGloballyCommand",
109+
"LspEnableLanguageServerInProjectCommand",
110+
"LspExecuteCommand",
111+
"LspExpandSelectionCommand",
112+
"LspExpandTreeItemCommand",
113+
"LspFoldAllCommand",
114+
"LspFoldCommand",
115+
"LspFormatCommand",
116+
"LspFormatDocumentCommand",
117+
"LspFormatDocumentRangeCommand",
118+
"LspGotoDiagnosticCommand",
119+
"LspHideRenameButtonsCommand",
120+
"LspHierarchyToggleCommand",
121+
"LspHoverCommand",
122+
"LspInlayHintClickCommand",
123+
"LspNextDiagnosticCommand",
124+
"LspOnDoubleClickCommand",
125+
"LspOpenLinkCommand",
126+
"LspOpenLocationCommand",
127+
"LspParseVscodePackageJson",
128+
"LspPrevDiagnosticCommand",
129+
"LspRefactorCommand",
130+
"LspResolveDocsCommand",
131+
"LspRestartServerCommand",
132+
"LspRunTextCommandHelperCommand",
133+
"LspSaveAllCommand",
134+
"LspSaveCommand",
135+
"LspSelectCompletionCommand",
136+
"LspSelectionAddCommand",
137+
"LspSelectionClearCommand",
138+
"LspSelectionSetCommand",
139+
"LspShowDiagnosticsPanelCommand",
140+
"LspShowScopeNameCommand",
141+
"LspSignatureHelpNavigateCommand",
142+
"LspSignatureHelpShowCommand",
143+
"LspSourceActionCommand",
144+
"LspSymbolDeclarationCommand",
145+
"LspSymbolDefinitionCommand",
146+
"LspSymbolImplementationCommand",
147+
"LspSymbolReferencesCommand",
148+
"LspSymbolRenameCommand",
149+
"LspSymbolTypeDefinitionCommand",
150+
"LspToggleCodeLensesCommand",
151+
"LspToggleHoverPopupsCommand",
152+
"LspToggleInlayHintsCommand",
153+
"LspToggleLogPanelLinesLimitCommand",
154+
"LspToggleServerPanelCommand",
155+
"LspTroubleshootServerCommand",
156+
"LspTypeHierarchyCommand",
157+
"LspUpdateLogPanelCommand",
158+
"LspUpdatePanelCommand",
159+
"LspWorkspaceSymbolsCommand",
160+
"TextChangeListener",
161+
"plugin_loaded",
162+
"plugin_unloaded",
163+
)
91164

92-
def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:
165+
166+
def _get_final_subclasses(derived: list[type], results: list[type]) -> None:
93167
for d in derived:
94168
d_subclasses = d.__subclasses__()
95169
if len(d_subclasses) > 0:
@@ -99,7 +173,7 @@ def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:
99173

100174

101175
def _register_all_plugins() -> None:
102-
plugin_classes: List[Type[AbstractPlugin]] = []
176+
plugin_classes: list[type[AbstractPlugin]] = []
103177
_get_final_subclasses(AbstractPlugin.__subclasses__(), plugin_classes)
104178
for plugin_class in plugin_classes:
105179
try:
@@ -112,6 +186,7 @@ def _register_all_plugins() -> None:
112186

113187
def _unregister_all_plugins() -> None:
114188
from LSP.plugin.core.sessions import _plugins
189+
115190
_plugins.clear()
116191
client_configs.external.clear()
117192
client_configs.all.clear()
@@ -132,7 +207,6 @@ def plugin_unloaded() -> None:
132207

133208

134209
class Listener(sublime_plugin.EventListener):
135-
136210
def on_exit(self) -> None:
137211
kill_all_subprocesses()
138212

@@ -187,7 +261,7 @@ def on_pre_close(self, view: sublime.View) -> None:
187261
tup[1](None)
188262
break
189263

190-
def on_post_window_command(self, window: sublime.Window, command_name: str, args: Optional[Dict[str, Any]]) -> None:
264+
def on_post_window_command(self, window: sublime.Window, command_name: str, args: dict[str, Any] | None) -> None:
191265
if command_name == "show_panel":
192266
wm = windows.lookup(window)
193267
if not wm:

0 commit comments

Comments
 (0)