Skip to content

Commit 0d423d4

Browse files
committed
Update python in test packages to 3.13. Fix finding projects with actions in CLI. Use older syntax to make finecode compatible with python 3.12+.
1 parent edb9e5f commit 0d423d4

19 files changed

Lines changed: 539 additions & 582 deletions

File tree

finecode/extension_runner/impls/process_executor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
from finecode_extension_api.interfaces import iprocessexecutor
1313

14+
P = typing.ParamSpec("P")
15+
T = typing.TypeVar("T")
16+
1417

1518
class ProcessExecutor(iprocessexecutor.IProcessExecutor):
1619
def __init__(self) -> None:
@@ -30,7 +33,7 @@ def activate(self) -> collections.abc.Iterator[None]:
3033
self._py_process_executor.shutdown()
3134
self._py_process_executor = None
3235

33-
async def submit[T, **P](
36+
async def submit(
3437
self, func: typing.Callable[P, T], *args: P.args, **kwargs: P.kwargs
3538
):
3639
if not self._active:

finecode/extension_runner/services.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import types
88
import typing
99
from pathlib import Path
10-
from typing import Any, Callable, TypeAliasType
1110

1211
from loguru import logger
1312

@@ -22,12 +21,12 @@
2221
class ActionFailedException(Exception): ...
2322

2423

25-
document_requester: Callable
26-
document_saver: Callable
24+
document_requester: typing.Callable
25+
document_saver: typing.Callable
2726
partial_result_sender: partial_result_sender_module.PartialResultSender
2827

2928

30-
def set_partial_result_sender(send_func: Callable) -> None:
29+
def set_partial_result_sender(send_func: typing.Callable) -> None:
3130
global partial_result_sender
3231
partial_result_sender = partial_result_sender_module.PartialResultSender(
3332
sender=send_func, wait_time_ms=300
@@ -85,13 +84,13 @@ async def update_config(
8584

8685

8786
def resolve_func_args_with_di(
88-
func: Callable,
89-
known_args: dict[str, Callable[[Any], Any]] | None = None,
87+
func: typing.Callable,
88+
known_args: dict[str, typing.Callable[[typing.Any], typing.Any]] | None = None,
9089
params_to_ignore: list[str] | None = None,
9190
):
9291
func_parameters = inspect.signature(func).parameters
9392
func_annotations = inspect.get_annotations(func, eval_str=True)
94-
args: dict[str, Any] = {}
93+
args: dict[str, typing.Any] = {}
9594
for param_name in func_parameters.keys():
9695
# default object constructor(__init__) has signature
9796
# __init__(self, *args, **kwargs)
@@ -121,7 +120,10 @@ def create_action_exec_info(action: domain.Action) -> domain.ActionExecInfo:
121120
logger.error(f"Error importing action type: {e}")
122121
raise e
123122

124-
if not isinstance(action_type_def, TypeAliasType):
123+
# typing.TypeAliasType is available in Python 3.12+
124+
if hasattr(typing, "TypeAliasType") and not isinstance(
125+
action_type_def, typing.TypeAliasType
126+
):
125127
raise Exception("Action definition expected to be a type")
126128

127129
action_type_alias = action_type_def.__value__
@@ -447,7 +449,7 @@ async def run_action(
447449
else:
448450
action_result.update(handler_result)
449451

450-
serialized_result: dict[str, Any] | str | None = None
452+
serialized_result: dict[str, typing.Any] | str | None = None
451453
result_format = "string"
452454
run_return_code = code_action.RunReturnCode.SUCCESS
453455
if isinstance(action_result, code_action.RunActionResult):

finecode/workspace_manager/cli_app/run.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ def find_projects_with_actions(
104104

105105
for project in ws_context.ws_projects.values():
106106
project_actions_names = [action.name for action in project.actions]
107+
# find which of requested actions are available in the project
107108
action_to_run_in_project = (
108-
ordered_set.OrderedSet(project_actions_names) - actions_set
109+
actions_set & ordered_set.OrderedSet(project_actions_names)
109110
)
110-
actions_by_project[project.dir_path] = list(action_to_run_in_project)
111+
relevant_actions_in_project = list(action_to_run_in_project)
112+
if len(relevant_actions_in_project) > 0:
113+
actions_by_project[project.dir_path] = relevant_actions_in_project
111114

112115
return actions_by_project
113116

@@ -284,7 +287,7 @@ async def run_actions_in_all_projects(
284287
result_output += "\n"
285288

286289
if run_in_many_projects:
287-
result_output += f"{str(project_dir_path)}\n"
290+
result_output += f"{click.style(str(project_dir_path), bold=True, underline=True)}\n"
288291

289292
for action_name, action_result in result_by_action.items():
290293
if run_many_actions:

finecode/workspace_manager/logger_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ def init_logger(trace: bool, stdout: bool = False):
1313
logger.remove()
1414
# disable logging raw messages
1515
# TODO: make configurable
16-
logger.configure(activation=[("pygls.protocol.json_rpc", False), ("pygls.feature_manager", False)])
16+
logger.configure(
17+
activation=[
18+
("pygls.protocol.json_rpc", False),
19+
("pygls.feature_manager", False),
20+
]
21+
)
1722
logs.save_logs_to_file(
1823
file_path=log_dir_path / "execution.log",
1924
log_level="TRACE" if trace else "INFO",

finecode/workspace_manager/runner/manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ async def update_runners(ws_context: context.WorkspaceContext) -> None:
227227
for runner in extension_runners:
228228
tg.create_task(
229229
_init_runner(
230-
runner, ws_context.ws_projects[runner.working_dir_path], ws_context
230+
runner,
231+
ws_context.ws_projects[runner.working_dir_path],
232+
ws_context,
231233
)
232234
)
233235
except ExceptionGroup as eg:
@@ -265,7 +267,9 @@ async def _init_runner(
265267
await notify_project_changed(project)
266268
runner.initialized_event.set()
267269
logger.exception(error)
268-
raise RunnerFailedToStart(f"Runner failed to notify about initialization: {error}")
270+
raise RunnerFailedToStart(
271+
f"Runner failed to notify about initialization: {error}"
272+
)
269273

270274
logger.debug("LSP Server initialized")
271275

finecode_extension_api/finecode_extension_api/interfaces/iprocessexecutor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import typing
22
from asyncio import BaseProtocol
33

4-
5-
T = typing.TypeVar('T')
6-
P = typing.ParamSpec('P')
4+
T = typing.TypeVar("T")
5+
P = typing.ParamSpec("P")
76

87

98
class IProcessExecutor(BaseProtocol):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.11
1+
3.13

0 commit comments

Comments
 (0)