Skip to content
Merged
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
4 changes: 4 additions & 0 deletions extensions/fine_python_flake8/fine_python_flake8/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ async def run(
payload: lint_action.LintRunPayload,
run_context: code_action.RunActionWithPartialResultsContext,
) -> None:
if self.config.select is not None and len(self.config.select) == 0:
# empty set of rules is selected, no need to run flake8
return None

file_paths = [file_path async for file_path in payload]

for file_path in file_paths:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import dataclasses
import pathlib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def run(
for env_info in payload.envs:
if payload.recreate and env_info.venv_dir_path.exists():
self.logger.debug(f"Remove virtualenv dir {env_info.venv_dir_path}")
self.file_manager.remove_dir(env_info.venv_dir_path)
await self.file_manager.remove_dir(env_info.venv_dir_path)

self.logger.info(f"Creating virtualenv {env_info.venv_dir_path}")
if not env_info.venv_dir_path.exists():
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions finecode_builtin_handlers/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[project]
name = "finecode_builtin_handlers"
version = "0.1.0"
description = "FineCode built-in handlers"
authors = [{ name = "Vladyslav Hnatiuk", email = "aders1234@gmail.com" }]
readme = "README.md"
requires-python = ">=3.11, < 3.14"
dependencies = ["finecode_extension_api==0.3.*", "tomlkit==0.11.*"]

[dependency-groups]
dev_workspace = ["finecode==0.3.*", "finecode_dev_common_preset==0.2.*"]

[tool.finecode.env.dev_workspace.dependencies]
finecode_dev_common_preset = { path = "../finecode_dev_common_preset", editable = true }
finecode = { path = "../", editable = true }
finecode_extension_runner = { path = "../finecode_extension_runner", editable = true }

[tool.finecode]
presets = [{ source = "finecode_dev_common_preset" }]
67 changes: 67 additions & 0 deletions finecode_builtin_handlers/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import atexit
import shutil
import sys
import tempfile

from setuptools import setup
from setuptools.command.build import build
from setuptools.command.build_ext import build_ext
from setuptools.command.build_py import build_py
from setuptools.command.egg_info import egg_info

# Create a single temp directory for all build operations
_TEMP_BUILD_DIR = None


def get_temp_build_dir(pkg_name):
global _TEMP_BUILD_DIR
if _TEMP_BUILD_DIR is None:
_TEMP_BUILD_DIR = tempfile.mkdtemp(prefix=f"{pkg_name}_build_")
atexit.register(lambda: shutil.rmtree(_TEMP_BUILD_DIR, ignore_errors=True))
return _TEMP_BUILD_DIR


class TempDirBuildMixin:
def initialize_options(self):
super().initialize_options()
temp_dir = get_temp_build_dir(self.distribution.get_name())
self.build_base = temp_dir


class TempDirEggInfoMixin:
def initialize_options(self):
super().initialize_options()
temp_dir = get_temp_build_dir(self.distribution.get_name())
self.egg_base = temp_dir


class CustomBuild(TempDirBuildMixin, build):
pass


class CustomBuildPy(TempDirBuildMixin, build_py):
pass


class CustomBuildExt(TempDirBuildMixin, build_ext):
pass


class CustomEggInfo(TempDirEggInfoMixin, egg_info):
def initialize_options(self):
# Don't use temp dir for editable installs
if "--editable" in sys.argv or "-e" in sys.argv:
egg_info.initialize_options(self)
else:
super().initialize_options()


setup(
name="finecode_builtin_handlers",
cmdclass={
"build": CustomBuild,
"build_py": CustomBuildPy,
"build_ext": CustomBuildExt,
"egg_info": CustomEggInfo,
},
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""FineCode Built-in handlers."""

from .dump_config import DumpConfigHandler
from .dump_config_save import DumpConfigSaveHandler
from .prepare_envs_install_deps import PrepareEnvsInstallDepsHandler
Expand All @@ -14,4 +16,4 @@
"PrepareRunnersInstallRunnerAndPresetsHandler",
"PrepareRunnersReadConfigsHandler",
"DumpConfigSaveHandler",
]
]
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import dataclasses
import pathlib

from finecode_extension_api import code_action
from finecode_extension_api.actions import dump_config as dump_config_action
from finecode_extension_api.interfaces import ifilemanager


@dataclasses.dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ilogger,
iprojectinfoprovider,
)
from finecode_extension_runner.action_handlers import dependency_config_utils
from finecode_builtin_handlers import dependency_config_utils


@dataclasses.dataclass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import dataclasses
import pathlib
import shutil
import typing

from finecode_extension_api import code_action
Expand All @@ -11,7 +10,7 @@
ilogger,
iprojectinfoprovider,
)
from finecode_extension_runner.action_handlers import dependency_config_utils
from finecode_builtin_handlers import dependency_config_utils


@dataclasses.dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ilogger,
iprojectinfoprovider,
)
from finecode_extension_runner.action_handlers import dependency_config_utils
from finecode_builtin_handlers import dependency_config_utils


@dataclasses.dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ilogger,
iprojectinfoprovider,
)
from finecode_extension_runner.action_handlers import dependency_config_utils
from finecode_builtin_handlers import dependency_config_utils


@dataclasses.dataclass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
from typing import Any, Protocol


Expand Down
1 change: 0 additions & 1 deletion finecode_extension_runner/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ readme = "README.md"
requires-python = ">=3.11, < 3.14"
dependencies = [
"loguru==0.7.*",
"tomlkit==0.11.*",
"click==8.1.*",
"pydantic==2.11.*",
"pygls==2.0.0-a6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
import pathlib
from typing import Any, Awaitable, Callable, Type, TypeVar
from typing import Any, Awaitable, Callable

try:
import fine_python_ast
Expand All @@ -12,7 +12,6 @@
except ImportError:
fine_python_mypy = None

from finecode_extension_api import code_action
from finecode_extension_api.interfaces import (
iactionrunner,
icache,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from typing import Any, TypeAlias
from typing import Any

from finecode_extension_api.interfaces import iactionrunner

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ def __init__(self, logger: ilogger.ILogger):
async def run(
self, cmd: str, cwd: Path | None = None, env: dict[str, str] | None = None
) -> icommandrunner.IAsyncProcess:
self.logger.debug(f"Async subprocess run: {cmd} in {cwd}")
log_msg = f"Async subprocess run: {cmd}"
if cwd is not None:
log_msg += f" in {cwd}"
self.logger.debug(log_msg)
# TODO: investigate why it works only with shell, not exec
async_subprocess = await asyncio.create_subprocess_shell(
cmd,
Expand All @@ -116,7 +119,10 @@ def run_sync(
self, cmd: str, cwd: Path | None = None, env: dict[str, str] | None = None
) -> icommandrunner.ISyncProcess:
cmd_parts = shlex.split(cmd)
self.logger.debug(f"Sync subprocess run: {cmd_parts}")
log_msg = f"Sync subprocess run: {cmd_parts}"
if cwd is not None:
log_msg += f' {cwd}'
self.logger.debug(log_msg)
async_subprocess = subprocess.Popen(
cmd_parts,
stdin=subprocess.PIPE,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies = [
"pygls==2.0.0-a6",
"finecode_extension_api==0.3.*",
"finecode_extension_runner==0.3.*",
"finecode_builtin_handlers==0.1.*",
"ordered-set==4.1.*",
"mcp==1.13.*",
"fine_python_virtualenv==0.1.*",
Expand Down
16 changes: 8 additions & 8 deletions src/finecode/base_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ source = "finecode_extension_api.actions.prepare_envs.PrepareEnvsAction"

[[tool.finecode.action.prepare_envs.handlers]]
name = "prepare_envs_dump_configs"
source = "finecode_extension_runner.action_handlers.PrepareEnvsReadConfigsHandler"
source = "finecode_builtin_handlers.PrepareEnvsReadConfigsHandler"
env = "dev_workspace"


[[tool.finecode.action.prepare_envs.handlers]]
name = "prepare_envs_install_deps"
source = "finecode_extension_runner.action_handlers.PrepareEnvsInstallDepsHandler"
source = "finecode_builtin_handlers.PrepareEnvsInstallDepsHandler"
env = "dev_workspace"


Expand All @@ -30,13 +30,13 @@ dependencies = ["fine_python_virtualenv==0.1.*"]

[[tool.finecode.action.prepare_dev_workspaces_envs.handlers]]
name = "prepare_envs_read_configs"
source = "finecode_extension_runner.action_handlers.PrepareEnvsReadConfigsHandler"
source = "finecode_builtin_handlers.PrepareEnvsReadConfigsHandler"
env = "dev_workspace"


[[tool.finecode.action.prepare_dev_workspaces_envs.handlers]]
name = "prepare_envs_install_deps"
source = "finecode_extension_runner.action_handlers.PrepareEnvsInstallDepsHandler"
source = "finecode_builtin_handlers.PrepareEnvsInstallDepsHandler"
env = "dev_workspace"


Expand All @@ -51,13 +51,13 @@ dependencies = ["fine_python_virtualenv==0.1.*"]

[[tool.finecode.action.prepare_runners.handlers]]
name = "prepare_runners_read_configs"
source = "finecode_extension_runner.action_handlers.PrepareRunnersReadConfigsHandler"
source = "finecode_builtin_handlers.PrepareRunnersReadConfigsHandler"
env = "dev_workspace"


[[tool.finecode.action.prepare_runners.handlers]]
name = "prepare_runners_install_runner_and_presets"
source = "finecode_extension_runner.action_handlers.PrepareRunnersInstallRunnerAndPresetsHandler"
source = "finecode_builtin_handlers.PrepareRunnersInstallRunnerAndPresetsHandler"
env = "dev_workspace"


Expand All @@ -66,13 +66,13 @@ source = "finecode_extension_api.actions.dump_config.DumpConfigAction"

[[tool.finecode.action.dump_config.handlers]]
name = "dump_config"
source = "finecode_extension_runner.action_handlers.DumpConfigHandler"
source = "finecode_builtin_handlers.DumpConfigHandler"
env = "dev_workspace"


[[tool.finecode.action.dump_config.handlers]]
name = "dump_config_save"
source = "finecode_extension_runner.action_handlers.DumpConfigSaveHandler"
source = "finecode_builtin_handlers.DumpConfigSaveHandler"
env = "dev_workspace"


Expand Down
6 changes: 4 additions & 2 deletions src/finecode/config/read_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,10 @@ def add_extension_runner_to_dependencies(project_config: dict[str, Any]) -> None
finecode_version = metadata.version("finecode")

for group_name, group_packages in deps_groups.items():
if group_name == "dev_workspace":
# skip `dev_workspace` because it contains finecode already
if group_name == "dev_workspace" or group_name == "runtime":
# - skip `dev_workspace` because it contains finecode already
# - skip `runtime` because FineCode doesn't start runner in runtime env, all
# development-related processes happen in `dev` env.
continue

group_packages.append(f"finecode_extension_runner == {finecode_version}")
Loading