Skip to content

Commit 71759d1

Browse files
authored
Merge pull request #20 from finecode-dev/builtin-handlers-package
Builtin handlers package
2 parents 7441aae + 2f72a52 commit 71759d1

File tree

22 files changed

+121
-28
lines changed

22 files changed

+121
-28
lines changed

extensions/fine_python_flake8/fine_python_flake8/action.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ async def run(
182182
payload: lint_action.LintRunPayload,
183183
run_context: code_action.RunActionWithPartialResultsContext,
184184
) -> None:
185+
if self.config.select is not None and len(self.config.select) == 0:
186+
# empty set of rules is selected, no need to run flake8
187+
return None
188+
185189
file_paths = [file_path async for file_path in payload]
186190

187191
for file_path in file_paths:

extensions/fine_python_pip/src/fine_python_pip/install_deps_in_env_handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import dataclasses
32
import pathlib
43

extensions/fine_python_virtualenv/src/fine_python_virtualenv/prepare_envs_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def run(
3737
for env_info in payload.envs:
3838
if payload.recreate and env_info.venv_dir_path.exists():
3939
self.logger.debug(f"Remove virtualenv dir {env_info.venv_dir_path}")
40-
self.file_manager.remove_dir(env_info.venv_dir_path)
40+
await self.file_manager.remove_dir(env_info.venv_dir_path)
4141

4242
self.logger.info(f"Creating virtualenv {env_info.venv_dir_path}")
4343
if not env_info.venv_dir_path.exists():

finecode_builtin_handlers/README.md

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[project]
2+
name = "finecode_builtin_handlers"
3+
version = "0.1.0"
4+
description = "FineCode built-in handlers"
5+
authors = [{ name = "Vladyslav Hnatiuk", email = "[email protected]" }]
6+
readme = "README.md"
7+
requires-python = ">=3.11, < 3.14"
8+
dependencies = ["finecode_extension_api==0.3.*", "tomlkit==0.11.*"]
9+
10+
[dependency-groups]
11+
dev_workspace = ["finecode==0.3.*", "finecode_dev_common_preset==0.2.*"]
12+
13+
[tool.finecode.env.dev_workspace.dependencies]
14+
finecode_dev_common_preset = { path = "../finecode_dev_common_preset", editable = true }
15+
finecode = { path = "../", editable = true }
16+
finecode_extension_runner = { path = "../finecode_extension_runner", editable = true }
17+
18+
[tool.finecode]
19+
presets = [{ source = "finecode_dev_common_preset" }]

finecode_builtin_handlers/setup.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import atexit
2+
import shutil
3+
import sys
4+
import tempfile
5+
6+
from setuptools import setup
7+
from setuptools.command.build import build
8+
from setuptools.command.build_ext import build_ext
9+
from setuptools.command.build_py import build_py
10+
from setuptools.command.egg_info import egg_info
11+
12+
# Create a single temp directory for all build operations
13+
_TEMP_BUILD_DIR = None
14+
15+
16+
def get_temp_build_dir(pkg_name):
17+
global _TEMP_BUILD_DIR
18+
if _TEMP_BUILD_DIR is None:
19+
_TEMP_BUILD_DIR = tempfile.mkdtemp(prefix=f"{pkg_name}_build_")
20+
atexit.register(lambda: shutil.rmtree(_TEMP_BUILD_DIR, ignore_errors=True))
21+
return _TEMP_BUILD_DIR
22+
23+
24+
class TempDirBuildMixin:
25+
def initialize_options(self):
26+
super().initialize_options()
27+
temp_dir = get_temp_build_dir(self.distribution.get_name())
28+
self.build_base = temp_dir
29+
30+
31+
class TempDirEggInfoMixin:
32+
def initialize_options(self):
33+
super().initialize_options()
34+
temp_dir = get_temp_build_dir(self.distribution.get_name())
35+
self.egg_base = temp_dir
36+
37+
38+
class CustomBuild(TempDirBuildMixin, build):
39+
pass
40+
41+
42+
class CustomBuildPy(TempDirBuildMixin, build_py):
43+
pass
44+
45+
46+
class CustomBuildExt(TempDirBuildMixin, build_ext):
47+
pass
48+
49+
50+
class CustomEggInfo(TempDirEggInfoMixin, egg_info):
51+
def initialize_options(self):
52+
# Don't use temp dir for editable installs
53+
if "--editable" in sys.argv or "-e" in sys.argv:
54+
egg_info.initialize_options(self)
55+
else:
56+
super().initialize_options()
57+
58+
59+
setup(
60+
name="finecode_builtin_handlers",
61+
cmdclass={
62+
"build": CustomBuild,
63+
"build_py": CustomBuildPy,
64+
"build_ext": CustomBuildExt,
65+
"egg_info": CustomEggInfo,
66+
},
67+
)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""FineCode Built-in handlers."""
2+
13
from .dump_config import DumpConfigHandler
24
from .dump_config_save import DumpConfigSaveHandler
35
from .prepare_envs_install_deps import PrepareEnvsInstallDepsHandler
@@ -14,4 +16,4 @@
1416
"PrepareRunnersInstallRunnerAndPresetsHandler",
1517
"PrepareRunnersReadConfigsHandler",
1618
"DumpConfigSaveHandler",
17-
]
19+
]
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import dataclasses
2-
import pathlib
32

43
from finecode_extension_api import code_action
54
from finecode_extension_api.actions import dump_config as dump_config_action
6-
from finecode_extension_api.interfaces import ifilemanager
75

86

97
@dataclasses.dataclass

0 commit comments

Comments
 (0)