Skip to content

Commit 5621785

Browse files
Use ternary
1 parent 6bb6e53 commit 5621785

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cursorless-talon/src/snippets/snippet_types.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ class ScopeType:
1010
type: str
1111

1212

13-
def to_scope_types(scope_types: str | list[str] | None) -> list[ScopeType] | None:
13+
def to_scope_types(scope_types: str | list[str]) -> list[ScopeType]:
1414
if isinstance(scope_types, str):
1515
return [ScopeType(scope_types)]
16-
elif scope_types is not None:
17-
return [ScopeType(st) for st in scope_types]
18-
return None
16+
return [ScopeType(st) for st in scope_types]
1917

2018

2119
# Community types
@@ -54,7 +52,7 @@ def create(
5452
):
5553
return CustomInsertionSnippet(
5654
snippet.body,
57-
to_scope_types(snippet.scopes),
55+
to_scope_types(snippet.scopes) if snippet.scopes else None,
5856
# languages will be missing if the user has an older version of community
5957
snippet.languages if hasattr(snippet, "languages") else None,
6058
substitutions=substitutions,

cursorless-talon/src/snippets/snippets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def cursorless_insert_snippet(
125125
"""Cursorless: Insert custom snippet <body>"""
126126
snippet = CustomInsertionSnippet(
127127
body,
128-
to_scope_types(scope_type),
128+
to_scope_types(scope_type) if scope_type else None,
129129
languages=None,
130130
substitutions=None,
131131
)

0 commit comments

Comments
 (0)