reykit 1.1.0__py3-none-any.whl → 1.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
reykit/rsystem.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, TypedDict, Literal, Optional, Union, overload
12
+ from typing import Any, TypedDict, Literal, overload
13
13
  from collections.abc import Callable, Iterable, Sequence
14
14
  from inspect import signature as inspect_signature, _ParameterKind, _empty
15
15
  from sys import path as sys_path, modules as sys_modules
@@ -110,17 +110,17 @@ ComputerInfo = TypedDict(
110
110
  NetWorkInfo = TypedDict(
111
111
  'NetWorkTable',
112
112
  {
113
- 'family': Optional[str],
114
- 'socket': Optional[str],
113
+ 'family': str | None,
114
+ 'socket': str | None,
115
115
  'local_ip': str,
116
116
  'local_port': int,
117
- 'remote_ip': Optional[str],
118
- 'remote_port': Optional[int],
119
- 'status': Optional[str],
120
- 'pid': Optional[int]
117
+ 'remote_ip': str | None,
118
+ 'remote_port': int | None,
119
+ 'status': str | None,
120
+ 'pid': int | None
121
121
  }
122
122
  )
123
- ProcessInfo = TypedDict('ProcessInfo', {'create_time': datetime, 'id': int, 'name': str, 'ports': Optional[list[int]]})
123
+ ProcessInfo = TypedDict('ProcessInfo', {'create_time': datetime, 'id': int, 'name': str, 'ports': list[int] | None})
124
124
 
125
125
 
126
126
  class RConfigSystem(object, metaclass=RConfigMeta):
@@ -208,7 +208,7 @@ def del_modules(path: str) -> list[str]:
208
208
  return deleted_dict
209
209
 
210
210
 
211
- def dos_command(command: Union[str, Iterable[str]]) -> str:
211
+ def dos_command(command: str | Iterable[str]) -> str:
212
212
  """
213
213
  Execute DOS command.
214
214
 
@@ -444,7 +444,7 @@ def is_number_str(
444
444
 
445
445
  def get_first_notnull(
446
446
  *values: Any,
447
- default: Union[None, Any, Literal['exception']] = None,
447
+ default: Any | Literal['exception'] | None = None,
448
448
  nulls: tuple = (None,)) -> Any:
449
449
  """
450
450
  Get the first value that is not null.
@@ -482,12 +482,12 @@ def get_first_notnull(
482
482
 
483
483
 
484
484
  @overload
485
- def get_name(obj: tuple, frame: int = 2) -> Optional[tuple[str, ...]]: ...
485
+ def get_name(obj: tuple, frame: int = 2) -> tuple[str, ...] | None: ...
486
486
 
487
487
  @overload
488
- def get_name(obj: Any, frame: int = 2) -> Optional[str]: ...
488
+ def get_name(obj: Any, frame: int = 2) -> str | None: ...
489
489
 
490
- def get_name(obj: Any, frame: int = 2) -> Optional[Union[str, tuple[str, ...]]]:
490
+ def get_name(obj: Any, frame: int = 2) -> str | tuple[str, ...] | None:
491
491
  """
492
492
  Get name of object or variable.
493
493
 
@@ -588,7 +588,7 @@ def get_stack_param(format_: Literal['floor'] = 'floor', limit: int = 2) -> dict
588
588
  @overload
589
589
  def get_stack_param(format_: Literal['full'] = 'floor', limit: int = 2) -> list[dict]: ...
590
590
 
591
- def get_stack_param(format_: Literal['floor', 'full'] = 'floor', limit: int = 2) -> Union[dict, list[dict]]:
591
+ def get_stack_param(format_: Literal['floor', 'full'] = 'floor', limit: int = 2) -> dict | list[dict]:
592
592
  """
593
593
  Get code stack parameters.
594
594
 
@@ -644,7 +644,7 @@ def get_stack_param(format_: Literal['floor', 'full'] = 'floor', limit: int = 2)
644
644
  def get_arg_info(func: Callable) -> list[
645
645
  dict[
646
646
  Literal['name', 'type', 'annotation', 'default'],
647
- Optional[str]
647
+ str | None
648
648
  ]
649
649
  ]:
650
650
  """
@@ -890,9 +890,9 @@ def get_process_table() -> list[ProcessInfo]:
890
890
 
891
891
 
892
892
  def search_process(
893
- id_: Optional[Union[int, Sequence[int]]] = None,
894
- name: Optional[Union[str, Sequence[str]]] = None,
895
- port: Optional[Union[str, int, Sequence[Union[str, int]]]] = None,
893
+ id_: int | Sequence[int] | None = None,
894
+ name: str | Sequence[str] | None = None,
895
+ port: str | int | Sequence[str | int] | None = None,
896
896
  ) -> list[Process]:
897
897
  """
898
898
  Search process by ID or name or port.
@@ -976,9 +976,9 @@ def search_process(
976
976
 
977
977
 
978
978
  def kill_process(
979
- id_: Optional[Union[int, Sequence[int]]] = None,
980
- name: Optional[Union[str, Sequence[str]]] = None,
981
- port: Optional[Union[str, int, Sequence[Union[str, int]]]] = None,
979
+ id_: int | Sequence[int] | None = None,
980
+ name: str | Sequence[str] | None = None,
981
+ port: str | int | Sequence[str | int] | None = None,
982
982
  ) -> list[Process]:
983
983
  """
984
984
  Search and kill process by ID or name or port.
@@ -1014,9 +1014,9 @@ def kill_process(
1014
1014
 
1015
1015
 
1016
1016
  def stop_process(
1017
- id_: Optional[Union[int, Sequence[int]]] = None,
1018
- name: Optional[Union[str, Sequence[str]]] = None,
1019
- port: Optional[Union[str, int, Sequence[Union[str, int]]]] = None,
1017
+ id_: int | Sequence[int] | None = None,
1018
+ name: str | Sequence[str] | None = None,
1019
+ port: str | int | Sequence[str | int] | None = None,
1020
1020
  ) -> list[Process]:
1021
1021
  """
1022
1022
  Search and stop process by ID or name or port.
@@ -1052,9 +1052,9 @@ def stop_process(
1052
1052
 
1053
1053
 
1054
1054
  def start_process(
1055
- id_: Optional[Union[int, Sequence[int]]] = None,
1056
- name: Optional[Union[str, Sequence[str]]] = None,
1057
- port: Optional[Union[str, int, Sequence[Union[str, int]]]] = None,
1055
+ id_: int | Sequence[int] | None = None,
1056
+ name: str | Sequence[str] | None = None,
1057
+ port: str | int | Sequence[str | int] | None = None,
1058
1058
  ) -> list[Process]:
1059
1059
  """
1060
1060
  Search and start process by ID or name or port.
@@ -1110,7 +1110,7 @@ def get_idle_port(min: int = 49152) -> int:
1110
1110
 
1111
1111
 
1112
1112
  def memory_read(
1113
- process: Union[int, str],
1113
+ process: int | str,
1114
1114
  dll: str,
1115
1115
  offset: int
1116
1116
  ) -> int:
@@ -1149,7 +1149,7 @@ def memory_read(
1149
1149
 
1150
1150
 
1151
1151
  def memory_write(
1152
- process: Union[int, str],
1152
+ process: int | str,
1153
1153
  dll: str,
1154
1154
  offset: int,
1155
1155
  value: int
@@ -1200,8 +1200,8 @@ def open_browser(url: str) -> bool:
1200
1200
 
1201
1201
  def popup_message(
1202
1202
  style: Literal['info', 'warn', 'error'] = 'info',
1203
- message: Optional[str] = None,
1204
- title: Optional[str] = None
1203
+ message: str | None = None,
1204
+ title: str | None = None
1205
1205
  ) -> None:
1206
1206
  """
1207
1207
  Pop up system message box.
@@ -1237,22 +1237,22 @@ def popup_message(
1237
1237
  @overload
1238
1238
  def popup_ask(
1239
1239
  style: Literal['yes_no_cancel'] = 'yes_no',
1240
- message: Optional[str] = None,
1241
- title: Optional[str] = None
1242
- ) -> Optional[bool]: ...
1240
+ message: str | None = None,
1241
+ title: str | None = None
1242
+ ) -> bool | None: ...
1243
1243
 
1244
1244
  @overload
1245
1245
  def popup_ask(
1246
1246
  style: Literal['yes_no', 'ok_cancel', 'retry_cancel'] = 'yes_no',
1247
- message: Optional[str] = None,
1248
- title: Optional[str] = None
1247
+ message: str | None = None,
1248
+ title: str | None = None
1249
1249
  ) -> bool: ...
1250
1250
 
1251
1251
  def popup_ask(
1252
1252
  style: Literal['yes_no', 'ok_cancel', 'retry_cancel', 'yes_no_cancel'] = 'yes_no',
1253
- message: Optional[str] = None,
1254
- title: Optional[str] = None
1255
- ) -> Optional[bool]:
1253
+ message: str | None = None,
1254
+ title: str | None = None
1255
+ ) -> bool | None:
1256
1256
  """
1257
1257
  Pop up system ask box.
1258
1258
 
@@ -1292,35 +1292,35 @@ def popup_ask(
1292
1292
  @overload
1293
1293
  def popup_select(
1294
1294
  style: Literal['file', 'save'] = 'file',
1295
- title : Optional[str] = None,
1296
- init_folder : Optional[str] = None,
1297
- init_file : Optional[str] = None,
1298
- filter_file : Optional[list[tuple[str, str | list[str]]]] = None
1295
+ title : str | None = None,
1296
+ init_folder : str | None = None,
1297
+ init_file : str | None = None,
1298
+ filter_file : list[tuple[str, str | list[str]]] | None = None
1299
1299
  ) -> str: ...
1300
1300
 
1301
1301
  @overload
1302
1302
  def popup_select(
1303
1303
  style: Literal['files'] = 'file',
1304
- title : Optional[str] = None,
1305
- init_folder : Optional[str] = None,
1306
- init_file : Optional[str] = None,
1307
- filter_file : Optional[list[tuple[str, str | list[str]]]] = None
1304
+ title : str | None = None,
1305
+ init_folder : str | None = None,
1306
+ init_file : str | None = None,
1307
+ filter_file : list[tuple[str, str | list[str]]] | None = None
1308
1308
  ) -> tuple[str, ...]: ...
1309
1309
 
1310
1310
  @overload
1311
1311
  def popup_select(
1312
1312
  style: Literal['folder'] = 'file',
1313
- title : Optional[str] = None,
1314
- init_folder : Optional[str] = None
1313
+ title : str | None = None,
1314
+ init_folder : str | None = None
1315
1315
  ) -> str: ...
1316
1316
 
1317
1317
  def popup_select(
1318
1318
  style: Literal['file', 'files', 'folder', 'save'] = 'file',
1319
- title : Optional[str] = None,
1320
- init_folder : Optional[str] = None,
1321
- init_file : Optional[str] = None,
1322
- filter_file : Optional[list[tuple[str, str | list[str]]]] = None
1323
- ) -> Union[str, tuple[str, ...]]:
1319
+ title : str | None = None,
1320
+ init_folder : str | None = None,
1321
+ init_file : str | None = None,
1322
+ filter_file : list[tuple[str, str | list[str]]] | None = None
1323
+ ) -> str | tuple[str, ...]:
1324
1324
  """
1325
1325
  Pop up system select box.
1326
1326
 
reykit/rtable.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, TypedDict, Optional, Union, overload
12
+ from typing import Any, TypedDict, overload
13
13
  from collections.abc import Iterable
14
14
  from os.path import abspath as os_abspath
15
15
  from pandas import DataFrame, ExcelWriter, isnull
@@ -34,13 +34,13 @@ __all__ = (
34
34
  )
35
35
 
36
36
 
37
- type Table = Union[list[dict], dict, CursorResult, DataFrame]
38
- SheetSet = TypedDict('SheetsSet', {'name': str, 'index': int, 'fields': Union[str, list[str]]})
37
+ type Table = list[dict] | dict | CursorResult | DataFrame
38
+ SheetSet = TypedDict('SheetsSet', {'name': str, 'index': int, 'fields': str | list[str]})
39
39
 
40
40
 
41
41
  def to_table(
42
- data: Union[Table, Iterable[Iterable]],
43
- fields: Optional[Iterable] = None
42
+ data: Table | Iterable[Iterable],
43
+ fields: Iterable | None = None
44
44
  ) -> list[dict]:
45
45
  """
46
46
  Convert data to table in `list[dict]` format, keys and keys sort of the dictionary are the same.
@@ -95,23 +95,23 @@ def to_table(
95
95
 
96
96
  @overload
97
97
  def to_dict(
98
- data: Union[Table, Iterable[Iterable]],
99
- key_field: Union[int, str] = 0,
98
+ data: Table | Iterable[Iterable],
99
+ key_field: int | str = 0,
100
100
  val_field: None = None
101
101
  ) -> dict[Any, dict]: ...
102
102
 
103
103
  @overload
104
104
  def to_dict(
105
- data: Union[Table, Iterable[Iterable]],
106
- key_field: Union[int, str] = 0,
107
- val_field: Union[int, str] = None
105
+ data: Table | Iterable[Iterable],
106
+ key_field: int | str = 0,
107
+ val_field: int | str = None
108
108
  ) -> dict: ...
109
109
 
110
110
  def to_dict(
111
- data: Union[Table, Iterable[Iterable]],
112
- key_field: Union[int, str] = 0,
113
- val_field: Optional[Union[int, str]] = None
114
- ) -> Union[dict[Any, dict], dict]:
111
+ data: Table | Iterable[Iterable],
112
+ key_field: int | str = 0,
113
+ val_field: int | str | None = None
114
+ ) -> dict[Any, dict] | dict:
115
115
  """
116
116
  Convert data as dictionary.
117
117
 
@@ -169,8 +169,8 @@ def to_dict(
169
169
 
170
170
 
171
171
  def to_list(
172
- data: Union[Table, Iterable[Iterable]],
173
- field: Union[int, str] = 0,
172
+ data: Table | Iterable[Iterable],
173
+ field: int | str = 0,
174
174
  ) -> list:
175
175
  """
176
176
  Convert data as list.
@@ -209,8 +209,8 @@ def to_list(
209
209
 
210
210
 
211
211
  def to_df(
212
- data: Union[Table, Iterable[Iterable]],
213
- fields: Optional[Iterable] = None
212
+ data: Table | Iterable[Iterable],
213
+ fields: Iterable | None = None
214
214
  ) -> DataFrame:
215
215
  """
216
216
  Convert data to table of `DataFrame` object.
@@ -253,8 +253,8 @@ def to_df(
253
253
 
254
254
 
255
255
  def to_json(
256
- data: Union[Table, Iterable[Iterable]],
257
- fields: Optional[Iterable] = None,
256
+ data: Table | Iterable[Iterable],
257
+ fields: Iterable | None = None,
258
258
  compact: bool = True
259
259
  ) -> str:
260
260
  """
@@ -283,8 +283,8 @@ def to_json(
283
283
 
284
284
 
285
285
  def to_text(
286
- data: Union[Table, Iterable[Iterable]],
287
- fields: Optional[Iterable] = None,
286
+ data: Table | Iterable[Iterable],
287
+ fields: Iterable | None = None,
288
288
  width: int = 100
289
289
  ) -> str:
290
290
  """
@@ -313,8 +313,8 @@ def to_text(
313
313
 
314
314
 
315
315
  def to_sql(
316
- data: Union[Table, Iterable[Iterable]],
317
- fields: Optional[Iterable] = None
316
+ data: Table | Iterable[Iterable],
317
+ fields: Iterable | None = None
318
318
  ) -> str:
319
319
  """
320
320
  Convert data to SQL string.
@@ -365,8 +365,8 @@ def to_sql(
365
365
 
366
366
 
367
367
  def to_html(
368
- data: Union[Table, Iterable[Iterable]],
369
- fields: Optional[Iterable] = None
368
+ data: Table | Iterable[Iterable],
369
+ fields: Iterable | None = None
370
370
  ) -> str:
371
371
  """
372
372
  Convert data to HTML string.
@@ -393,9 +393,9 @@ def to_html(
393
393
 
394
394
 
395
395
  def to_csv(
396
- data: Union[Table, Iterable[Iterable]],
396
+ data: Table | Iterable[Iterable],
397
397
  path: str = 'data.csv',
398
- fields: Optional[Iterable] = None
398
+ fields: Iterable | None = None
399
399
  ) -> str:
400
400
  """
401
401
  Convert data to save CSV format file.
@@ -429,10 +429,10 @@ def to_csv(
429
429
 
430
430
 
431
431
  def to_excel(
432
- data: Union[Table, Iterable[Iterable]],
432
+ data: Table | Iterable[Iterable],
433
433
  path: str = 'data.xlsx',
434
- group_field: Optional[str] = None,
435
- sheets_set: dict[Union[str, int], SheetSet] = {}
434
+ group_field: str | None = None,
435
+ sheets_set: dict[str | int, SheetSet] = {}
436
436
  ) -> str:
437
437
  """
438
438
  Convert data to save Excel format file and return sheet name and sheet data.
reykit/rtext.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Literal, Optional
12
+ from typing import Any, Literal
13
13
  from collections.abc import Iterable
14
14
  from decimal import Decimal
15
15
  from pprint import pformat as pprint_pformat
@@ -278,7 +278,7 @@ def join_filter_text(data: Iterable, char: str = ',', filter_: tuple = (None, ''
278
278
 
279
279
  def add_text_frame(
280
280
  *texts: str,
281
- title: Optional[str],
281
+ title: str | None,
282
282
  width: int,
283
283
  frame: Literal['full', 'half', 'top', 'half_plain', 'top_plain']
284
284
  ) -> str:
@@ -289,7 +289,7 @@ def add_text_frame(
289
289
  ----------
290
290
  texts : Texts.
291
291
  title : Frame title.
292
- - `Union[None, Literal['']]`: No title.
292
+ - `None | Literal['']`: No title.
293
293
  - `str`: Use this value as the title.
294
294
  width : Frame width.
295
295
  frame : Frame type.
reykit/rtime.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, TypedDict, Literal, Optional, Union, overload, NoReturn
12
+ from typing import Any, TypedDict, Literal, overload, NoReturn
13
13
  from collections.abc import Callable
14
14
  from pandas import (
15
15
  DataFrame,
@@ -47,7 +47,7 @@ __all__ = (
47
47
  )
48
48
 
49
49
 
50
- RecordData = TypedDict('RecordData', {'timestamp': int, 'datetime': datetime_datetime, 'timedelta': Optional[datetime_timedelta], 'note': Optional[str]})
50
+ RecordData = TypedDict('RecordData', {'timestamp': int, 'datetime': datetime_datetime, 'timedelta': datetime_timedelta | None, 'note': str | None})
51
51
 
52
52
 
53
53
  @overload
@@ -78,13 +78,7 @@ def now(
78
78
  'time_str',
79
79
  'timestamp'
80
80
  ] = 'datetime'
81
- ) -> Union[
82
- datetime_datetime,
83
- datetime_date,
84
- datetime_time,
85
- str,
86
- int
87
- ]:
81
+ ) -> datetime_datetime | datetime_date | datetime_time | str | int:
88
82
  """
89
83
  Get the now time.
90
84
 
@@ -126,15 +120,7 @@ def now(
126
120
 
127
121
  @overload
128
122
  def time_to(
129
- obj: Union[
130
- datetime_datetime,
131
- datetime_date,
132
- datetime_time,
133
- datetime_timedelta,
134
- time_struct_time,
135
- pd_timestamp,
136
- pd_timedelta
137
- ],
123
+ obj: datetime_datetime | datetime_date | datetime_time | datetime_timedelta | time_struct_time | pd_timestamp | pd_timedelta,
138
124
  decimal: bool = False,
139
125
  raising: bool = True
140
126
  ) -> str: ...
@@ -241,13 +227,7 @@ def time_to(
241
227
 
242
228
  def text_to_time(
243
229
  string: str
244
- ) -> Optional[
245
- Union[
246
- datetime_datetime,
247
- datetime_date,
248
- datetime_time
249
- ]
250
- ]:
230
+ ) -> datetime_datetime | datetime_date | datetime_time | None:
251
231
  """
252
232
  Convert text to time object.
253
233
 
@@ -332,11 +312,11 @@ def text_to_time(
332
312
  def to_time(
333
313
  obj: str,
334
314
  raising: bool = True
335
- ) -> Union[datetime_datetime, datetime_date, datetime_time]: ...
315
+ ) -> datetime_datetime | datetime_date | datetime_time: ...
336
316
 
337
317
  @overload
338
318
  def to_time(
339
- obj: Union[time_struct_time, float],
319
+ obj: time_struct_time | float,
340
320
  raising: bool = True
341
321
  ) -> datetime_datetime: ...
342
322
 
@@ -413,7 +393,7 @@ def to_time(
413
393
 
414
394
  def sleep(
415
395
  *thresholds: float,
416
- precision: Optional[int] = None
396
+ precision: int | None = None
417
397
  ) -> float:
418
398
  """
419
399
  Sleep random seconds.
@@ -452,7 +432,7 @@ def wait(
452
432
  func: Callable[..., bool],
453
433
  *args: Any,
454
434
  _interval: float = 1,
455
- _timeout: Optional[float] = None,
435
+ _timeout: float | None = None,
456
436
  **kwargs: Any
457
437
  ) -> float:
458
438
  """
@@ -522,7 +502,7 @@ class RTimeMark():
522
502
  self.record: dict[int, RecordData] = {}
523
503
 
524
504
 
525
- def mark(self, note: Optional[str] = None) -> int:
505
+ def mark(self, note: str | None = None) -> int:
526
506
  """
527
507
  Marking now time.
528
508
 
@@ -560,7 +540,7 @@ class RTimeMark():
560
540
  return index
561
541
 
562
542
 
563
- def report(self, title: Optional[str] = None) -> DataFrame:
543
+ def report(self, title: str | None = None) -> DataFrame:
564
544
  """
565
545
  Print and return time mark information table.
566
546
 
reykit/rtype.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Optional, Self
12
+ from typing import Any, Self
13
13
  from collections.abc import Callable
14
14
 
15
15
 
@@ -86,7 +86,7 @@ class RSingleton(object):
86
86
  When instantiated, method `__singleton__` will be called only once, and will accept arguments.
87
87
  """
88
88
 
89
- _instance: Optional[Self] = None
89
+ _instance: Self | None = None
90
90
 
91
91
 
92
92
  def __new__(self, *arg: Any, **kwargs: Any) -> Self:
reykit/rwrap.py CHANGED
@@ -9,7 +9,7 @@
9
9
  """
10
10
 
11
11
 
12
- from typing import Any, Optional, Union, Literal, overload
12
+ from typing import Any, Literal, overload
13
13
  from collections.abc import Callable
14
14
  from io import IOBase, StringIO
15
15
  from inspect import getdoc
@@ -78,7 +78,7 @@ def wrap_frame(decorator: Callable) -> Callable:
78
78
 
79
79
  # Decorate Decorator.
80
80
  @overload
81
- def wrap(func: Callable, *args: Any, _execute: None = None, **kwargs: Any) -> Union[Callable, Any]: ...
81
+ def wrap(func: Callable, *args: Any, _execute: None = None, **kwargs: Any) -> Callable | Any: ...
82
82
 
83
83
  @overload
84
84
  def wrap(func: Callable, *args: Any, _execute: Literal[True] = None, **kwargs: Any) -> Any: ...
@@ -87,7 +87,7 @@ def wrap_frame(decorator: Callable) -> Callable:
87
87
  def wrap(func: Callable, *args: Any, _execute: Literal[False] = None, **kwargs: Any) -> Callable: ...
88
88
 
89
89
  @functools_wraps(decorator)
90
- def wrap(func: Callable, *args: Any, _execute: Optional[bool] = None, **kwargs: Any) -> Union[Callable, Any]:
90
+ def wrap(func: Callable, *args: Any, _execute: bool | None = None, **kwargs: Any) -> Callable | Any:
91
91
  """
92
92
  Decorative shell.
93
93
 
@@ -167,7 +167,7 @@ def wrap_runtime(
167
167
  *args: Any,
168
168
  _return_report: bool = False,
169
169
  **kwargs: Any
170
- ) -> Union[Any, tuple[Any, str]]:
170
+ ) -> Any | tuple[Any, str]:
171
171
  """
172
172
  Decorator, print or return runtime report of the function.
173
173
 
@@ -260,19 +260,19 @@ def wrap_thread(
260
260
  def wrap_exc(
261
261
  func: Callable,
262
262
  *args: Any,
263
- _exception: Union[BaseException, tuple[BaseException, ...]] = BaseException,
264
- _handler: Optional[Callable] = None,
263
+ _exception: BaseException | tuple[BaseException, ...] = BaseException,
264
+ _handler: Callable | None = None,
265
265
  **kwargs: Any
266
- ) -> Optional[Any]: ...
266
+ ) -> Any | None: ...
267
267
 
268
268
  @wrap_frame
269
269
  def wrap_exc(
270
270
  func: Callable,
271
271
  *args: Any,
272
- _exception: Union[BaseException, tuple[BaseException, ...]] = BaseException,
273
- _handler: Optional[Callable] = None,
272
+ _exception: BaseException | tuple[BaseException, ...] = BaseException,
273
+ _handler: Callable | None = None,
274
274
  **kwargs: Any
275
- ) -> Optional[Any]:
275
+ ) -> Any | None:
276
276
  """
277
277
  Decorator, execute function with `try` and `except` syntax.
278
278
 
@@ -307,8 +307,8 @@ def wrap_exc(
307
307
  def wrap_retry(
308
308
  func: Callable,
309
309
  *args: Any,
310
- _report: Optional[str] = None,
311
- _exception: Union[BaseException, tuple[BaseException, ...]] = BaseException,
310
+ _report: str | None = None,
311
+ _exception: BaseException | tuple[BaseException, ...] = BaseException,
312
312
  _try_total: int = 1,
313
313
  _try_count: int = 0,
314
314
  **kwargs: Any
@@ -318,8 +318,8 @@ def wrap_retry(
318
318
  def wrap_retry(
319
319
  func: Callable,
320
320
  *args: Any,
321
- _report: Optional[str] = None,
322
- _exception: Union[BaseException, tuple[BaseException, ...]] = BaseException,
321
+ _report: str | None = None,
322
+ _exception: BaseException | tuple[BaseException, ...] = BaseException,
323
323
  _try_total: int = 1,
324
324
  _try_count: int = 0,
325
325
  **kwargs: Any
@@ -569,7 +569,7 @@ def wrap_cache(
569
569
  def wrap_redirect_stdout(
570
570
  func: Callable,
571
571
  *args: Any,
572
- _redirect: Optional[Union[list, IOBase]] = None,
572
+ _redirect: list | IOBase | None = None,
573
573
  **kwargs: Any
574
574
  ) -> Any: ...
575
575
 
@@ -577,7 +577,7 @@ def wrap_redirect_stdout(
577
577
  def wrap_redirect_stdout(
578
578
  func: Callable,
579
579
  *args: Any,
580
- _redirect: Optional[Union[list, IOBase]] = None,
580
+ _redirect: list | IOBase | None = None,
581
581
  **kwargs: Any
582
582
  ) -> Any:
583
583
  """
reykit/rzip.py CHANGED
@@ -10,7 +10,6 @@
10
10
 
11
11
 
12
12
  from __future__ import annotations
13
- from typing import Optional
14
13
  from zipfile import ZipFile, is_zipfile, ZIP_DEFLATED
15
14
  from os import getcwd as os_getcwd, walk as os_walk
16
15
  from os.path import join as os_join, isfile as os_isfile
@@ -27,7 +26,7 @@ __all__ = (
27
26
 
28
27
  def compress(
29
28
  obj_path: str,
30
- build_dir: Optional[str] = None,
29
+ build_dir: str | None = None,
31
30
  overwrite: bool = True
32
31
  ) -> None:
33
32
  """
@@ -82,8 +81,8 @@ def compress(
82
81
 
83
82
  def decompress(
84
83
  obj_path: str,
85
- build_dir: Optional[str] = None,
86
- password: Optional[str] = None
84
+ build_dir: str | None = None,
85
+ password: str | None = None
87
86
  ) -> None:
88
87
  """
89
88
  Decompress compressed object.
@@ -114,7 +113,7 @@ def decompress(
114
113
 
115
114
  def zip(
116
115
  obj_path: str,
117
- build_dir: Optional[str] = None
116
+ build_dir: str | None = None
118
117
  ) -> None:
119
118
  """
120
119
  Automatic judge and compress or decompress object.