aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/pybuild.py
diff options
context:
space:
mode:
authorkorsunandrei <korsunandrei@yandex-team.com>2024-01-24 19:40:09 +0300
committerkorsunandrei <korsunandrei@yandex-team.com>2024-01-24 20:03:12 +0300
commita47b1fb37eb32d1a5d55d8be2af832cc4406935a (patch)
treee8e00ec63e85180adc9ae99e8848a288aa40ad03 /build/plugins/pybuild.py
parentd8c20af07f90f083d5e3ca61d87864e4dacf6999 (diff)
downloadydb-a47b1fb37eb32d1a5d55d8be2af832cc4406935a.tar.gz
feat yamake: add ruff wrapper and ya make macro
Diffstat (limited to 'build/plugins/pybuild.py')
-rw-r--r--build/plugins/pybuild.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/build/plugins/pybuild.py b/build/plugins/pybuild.py
index 23ace17669..e58f0906cd 100644
--- a/build/plugins/pybuild.py
+++ b/build/plugins/pybuild.py
@@ -145,6 +145,8 @@ def add_python_lint_checks(unit, py_ver, files):
resolved_files.append(resolved)
return resolved_files
+ upath = unit.path()[3:]
+
no_lint_value = get_no_lint_value(unit)
if no_lint_value == "none":
no_lint_allowed_paths = (
@@ -161,8 +163,6 @@ def add_python_lint_checks(unit, py_ver, files):
"yt/python/", # YT-20053
)
- upath = unit.path()[3:]
-
if not upath.startswith(no_lint_allowed_paths):
ymake.report_configure_error("NO_LINT() is allowed only in " + ", ".join(no_lint_allowed_paths))
@@ -193,6 +193,27 @@ def add_python_lint_checks(unit, py_ver, files):
params += ["EXTRA_PARAMS"] + extra_params
unit.on_add_linter_check(params)
+ # ruff related stuff
+ if unit.get('STYLE_RUFF_VALUE') == 'yes':
+ if no_lint_value in ("none", "none_internal"):
+ ymake.report_configure_error(
+ 'NO_LINT() and STYLE_RUFF() can\'t be enabled both at the same time',
+ )
+ # temporary allow using ruff for taxi only
+ ruff_allowed_paths = ("taxi/",)
+ if not upath.startswith(ruff_allowed_paths):
+ ymake.report_configure_error("STYLE_RUFF() is allowed only in " + ", ".join(ruff_allowed_paths))
+
+ resolved_files = get_resolved_files()
+ if resolved_files:
+ resource = "build/external_resources/ruff"
+ params = ["ruff", "tools/ruff_linter/bin/ruff_linter"]
+ params += ["FILES"] + resolved_files
+ params += ["GLOBAL_RESOURCES", resource]
+ ruff_cfg = unit.get('STYLE_RUFF_PYPROJECT_VALUE') or 'build/config/tests/ruff/ruff.toml'
+ params += ['CONFIGS', ruff_cfg]
+ unit.on_add_linter_check(params)
+
if files and unit.get('STYLE_PYTHON_VALUE') == 'yes' and is_py3(unit):
resolved_files = get_resolved_files()
if resolved_files: