Skip to content

Commit 3517c62

Browse files
committed
modified: src/click_repl/_globals.py
modified: src/click_repl/_repl.py modified: src/click_repl/bottom_bar.py modified: src/click_repl/completer.py modified: src/click_repl/core.py modified: src/click_repl/parser.py modified: src/click_repl/utils.py
1 parent d963901 commit 3517c62

File tree

7 files changed

+33
-39
lines changed

7 files changed

+33
-39
lines changed

src/click_repl/_globals.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import sys
1212
import typing as t
1313
from threading import local
14-
from typing import List
1514
from typing import NoReturn
1615

1716
import click
@@ -172,7 +171,7 @@
172171

173172
# To store the ReplContext objects generated throughout the Runtime.
174173
_locals = local()
175-
ctx_stack: List[ReplContext] = []
174+
ctx_stack: list[ReplContext] = []
176175
_locals.ctx_stack = ctx_stack
177176
# ctx_stack = _locals.ctx_stack
178177

src/click_repl/_repl.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import sys
1010
import traceback
1111
from typing import Any
12-
from typing import Dict
1312
from typing import Sequence
1413
from typing import cast
1514

@@ -81,11 +80,11 @@ class Repl:
8180
def __init__(
8281
self,
8382
ctx: Context,
84-
prompt_kwargs: Dict[str, Any] = {},
83+
prompt_kwargs: dict[str, Any] = {},
8584
completer_cls: type[Completer] | None = ClickCompleter,
8685
validator_cls: type[Validator] | None = ClickValidator,
87-
completer_kwargs: Dict[str, Any] = {},
88-
validator_kwargs: Dict[str, Any] = {},
86+
completer_kwargs: dict[str, Any] = {},
87+
validator_kwargs: dict[str, Any] = {},
8988
internal_command_prefix: str | None = ":",
9089
system_command_prefix: str | None = "!",
9190
) -> None:
@@ -144,8 +143,8 @@ def get_command() -> str:
144143
self.get_command = get_command
145144

146145
def _bootstrap_completer_kwargs(
147-
self, completer_cls: type[Completer] | None, completer_kwargs: Dict[str, Any]
148-
) -> Dict[str, Any]:
146+
self, completer_cls: type[Completer] | None, completer_kwargs: dict[str, Any]
147+
) -> dict[str, Any]:
149148
"""
150149
Generates bootstrap keyword arguments for initializing a
151150
`prompt_toolkit.completer.Completer` object, either using
@@ -180,8 +179,8 @@ def _bootstrap_completer_kwargs(
180179
return default_completer_kwargs
181180

182181
def _bootstrap_validator_kwargs(
183-
self, validator_cls: type[Validator] | None, validator_kwargs: Dict[str, Any]
184-
) -> Dict[str, Any]:
182+
self, validator_cls: type[Validator] | None, validator_kwargs: dict[str, Any]
183+
) -> dict[str, Any]:
185184
"""
186185
Generates bootstrap keyword arguments for initializing a
187186
`prompt_toolkit.validation.Validator` object, either
@@ -222,11 +221,11 @@ def _bootstrap_validator_kwargs(
222221
def _bootstrap_prompt_kwargs(
223222
self,
224223
completer_cls: type[Completer] | None,
225-
completer_kwargs: Dict[str, Any],
224+
completer_kwargs: dict[str, Any],
226225
validator_cls: type[Validator] | None,
227-
validator_kwargs: Dict[str, Any],
228-
prompt_kwargs: Dict[str, Any],
229-
) -> Dict[str, Any]:
226+
validator_kwargs: dict[str, Any],
227+
prompt_kwargs: dict[str, Any],
228+
) -> dict[str, Any]:
230229
if not ISATTY:
231230
return {}
232231

@@ -373,7 +372,7 @@ def loop(self) -> None:
373372

374373
def repl(
375374
group_ctx: Context,
376-
prompt_kwargs: Dict[str, Any] = {},
375+
prompt_kwargs: dict[str, Any] = {},
377376
cls: type[Repl] = Repl,
378377
**attrs: Any,
379378
) -> None:

src/click_repl/bottom_bar.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from __future__ import annotations
88

99
import typing as t
10-
from typing import List
1110
from typing import Tuple
1211

1312
import click
@@ -35,7 +34,7 @@
3534

3635

3736
class ParamInfo(TypedDict):
38-
name: Tuple[str, str]
37+
name: tuple[str, str]
3938
type_info: StyleAndTextTuples
4039
nargs_info: StyleAndTextTuples
4140

@@ -306,7 +305,7 @@ def get_param_nargs_info(
306305
assert self.state is not None, "state cannot be None"
307306

308307
# Calculate the number of non-None values received for the parameter.
309-
param_values: List[str] = (
308+
param_values: list[str] = (
310309
self.state.current_ctx.params[param.name] or [] # type:ignore[index]
311310
)
312311

src/click_repl/completer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def get_completion_for_boolean_type(
441441

442442
_incomplete = incomplete.expand_envvars()
443443

444-
boolean_mapping: Dict[str, Tuple[str, ...]] = {
444+
boolean_mapping: dict[str, Tuple[str, ...]] = {
445445
"true": ("1", "true", "t", "yes", "y", "on"),
446446
"false": ("0", "false", "f", "no", "n", "off"),
447447
}

src/click_repl/core.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import Any
1111
from typing import Callable
1212
from typing import Dict
13-
from typing import List
1413

1514
import click
1615
from click import Context
@@ -32,11 +31,11 @@
3231

3332
class InfoDict(TypedDict):
3433
group_ctx: Context
35-
prompt_kwargs: Dict[str, Any]
34+
prompt_kwargs: dict[str, Any]
3635
session: _PromptSession | None
3736
internal_command_system: InternalCommandSystem
3837
parent: ReplContext | None
39-
_history: List[str]
38+
_history: list[str]
4039
current_state: ReplParsingState | None
4140
bottombar: BottomBar | None
4241

@@ -93,7 +92,7 @@ def __init__(
9392
group_ctx: Context,
9493
internal_command_system: InternalCommandSystem,
9594
bottombar: BottomBar | None = None,
96-
prompt_kwargs: Dict[str, Any] = {},
95+
prompt_kwargs: dict[str, Any] = {},
9796
parent: ReplContext | None = None,
9897
) -> None:
9998
session: _PromptSession | None
@@ -109,7 +108,7 @@ def __init__(
109108
self.session = session
110109
self.bottombar = bottombar
111110

112-
self._history: List[str] = []
111+
self._history: list[str] = []
113112
self.internal_command_system = internal_command_system
114113
self.group_ctx: Final[Context] = group_ctx
115114
self.prompt_kwargs = prompt_kwargs
@@ -231,7 +230,7 @@ def __init__(
231230
prompt: str = "> ",
232231
startup: Callable[[], None] | None = None,
233232
cleanup: Callable[[], None] | None = None,
234-
repl_kwargs: Dict[str, Any] = {},
233+
repl_kwargs: dict[str, Any] = {},
235234
**attrs: Any,
236235
) -> None:
237236
attrs["invoke_without_command"] = True

src/click_repl/parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def split_arg_string(string: str, posix: bool = True) -> List[str]:
8080
lex = shlex(string, posix=posix, punctuation_chars=True)
8181
lex.whitespace_split = True
8282
lex.escape = ""
83-
out: List[str] = []
83+
out: list[str] = []
8484

8585
try:
8686
out.extend(lex)
@@ -186,15 +186,15 @@ def __init__(
186186
self,
187187
cli_ctx: Context,
188188
current_ctx: Context,
189-
args: Tuple[str, ...],
189+
args: tuple[str, ...],
190190
) -> None:
191191
self.cli_ctx = cli_ctx
192192
self.cli = t.cast(MultiCommand, self.cli_ctx.command)
193193

194194
self.current_ctx = current_ctx
195195
self.args = args
196196

197-
self.remaining_params: List[Parameter] = []
197+
self.remaining_params: list[Parameter] = []
198198
self.double_dash_found = getattr(current_ctx, "_double_dash_found", False)
199199

200200
self.current_group, self.current_command, self.current_param = self.parse()
@@ -218,7 +218,7 @@ def __repr__(self) -> str:
218218
return f'"{str(self)}"'
219219

220220
def __key(self) -> _KEY:
221-
keys: List[InfoDict | None] = []
221+
keys: list[InfoDict | None] = []
222222

223223
for i in (
224224
self.current_group,
@@ -364,7 +364,7 @@ def parse_param_arg(self, current_command: Command) -> click.Argument | None:
364364
def _resolve_repl_parsing_state(
365365
cli_ctx: Context,
366366
current_ctx: Context,
367-
args: Tuple[str, ...],
367+
args: tuple[str, ...],
368368
) -> ReplParsingState:
369369
return ReplParsingState(cli_ctx, current_ctx, args)
370370

src/click_repl/utils.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
from collections.abc import Iterator
1111
from functools import lru_cache
1212
from typing import Any
13-
from typing import Dict
1413
from typing import Iterable
15-
from typing import List
1614
from typing import Tuple
1715

1816
import click
@@ -38,7 +36,7 @@
3836

3937

4038
def append_classname_to_all_tokens(
41-
tokens_list: StyleAndTextTuples, classes: List[str] = []
39+
tokens_list: StyleAndTextTuples, classes: list[str] = []
4240
) -> StyleAndTextTuples:
4341
if not classes:
4442
return tokens_list
@@ -126,12 +124,12 @@ def is_param_value_incomplete(
126124
)
127125

128126

129-
def get_option_flag_sep(options: List[str]) -> str:
127+
def get_option_flag_sep(options: list[str]) -> str:
130128
any_prefix_is_slash = any(split_opt(opt)[0] == "/" for opt in options)
131129
return ";" if any_prefix_is_slash else "/"
132130

133131

134-
def join_options(options: List[str]) -> Tuple[List[str], str]:
132+
def join_options(options: list[str]) -> Tuple[list[str], str]:
135133
# Same implementation as click.formatting.join_options function, but much simpler.
136134
return sorted(options, key=len), get_option_flag_sep(options)
137135

@@ -279,10 +277,10 @@ def get_info_dict(
279277
def _generate_next_click_ctx(
280278
multicommand: MultiCommand,
281279
parent_ctx: Context,
282-
args: Tuple[str, ...],
280+
args: tuple[str, ...],
283281
proxy: bool = False,
284-
**ctx_kwargs: Dict[str, Any],
285-
) -> Tuple[Context, Command | None]:
282+
**ctx_kwargs: dict[str, Any],
283+
) -> tuple[Context, Command | None]:
286284
if not args:
287285
return parent_ctx, None
288286

@@ -312,7 +310,7 @@ def _generate_next_click_ctx(
312310

313311

314312
@lru_cache(maxsize=3)
315-
def _resolve_context(ctx: Context, args: Tuple[str, ...], proxy: bool = False) -> Context:
313+
def _resolve_context(ctx: Context, args: tuple[str, ...], proxy: bool = False) -> Context:
316314
while args:
317315
command = ctx.command
318316

0 commit comments

Comments
 (0)