Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize scripts/clone_helixlsp_config.py for performance #102

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions scripts/clone_helix_lsp_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

for lsp in lsps.values():
# Margs command and args
lsp["cmd"] = [lsp["command"], *lsp.get("args", [])]
cmd = [lsp["command"], *lsp.get("args", [])]
lsp["cmd"] = cmd
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think there's any need for this: cmd is not actually reused anywhere, so this change is just adding a variable assignment unnecessarily.

del lsp["command"]
if "args" in lsp:
del lsp["args"]
Expand All @@ -23,9 +24,9 @@
# Assign languages to LSPs
for lang in c.get("language", []):
for name in lang.get("language-servers", []):
if lsp := lsps.get(name, {}):
if "languages" not in lsp:
lsp["languages"] = set()
lsp["languages"].add(lang["name"])
lsp = lsps.get(name, {})
if "languages" not in lsp:
lsp["languages"] = set()
lsp["languages"].add(lang["name"])
Copy link
Owner

Choose a reason for hiding this comment

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

This change I'm happy to keep


print(lsps)
11 changes: 2 additions & 9 deletions scripts/debug_vt100_input.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
#!/usr/bin/env python
"""Parse vt100 input and print keys."""

from __future__ import annotations

import sys
from typing import TYPE_CHECKING

from prompt_toolkit.input.vt100 import raw_mode

from euporie.core.io import Vt100Parser
from euporie.core.keys import Keys

if TYPE_CHECKING:
from prompt_toolkit.key_binding import KeyPress


def callback(key_press: KeyPress) -> None:
Copy link
Owner

Choose a reason for hiding this comment

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

I have chosen to use type annotations in this code-base. because I find it helps me catch errors and bugs.

Why do you think they should be removed from this script in particular?

def callback(key_press):
"""Run when a key press event is received."""
print(key_press)
if key_press.key == Keys.ControlC:
Expand All @@ -24,7 +17,7 @@ def callback(key_press: KeyPress) -> None:
sys.exit(0)


def main() -> None:
def main():
"""Run the main event loop."""
print("\x1b[>4;1m")
print("\x1b[>1u")
Expand Down