diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-12-12 15:00:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 15:00:43 +0000 |
commit | 42701242eaf5be980cb935631586d0e90b82641c (patch) | |
tree | 6dbf5fcd37d3c16591e196c4a69d166e3ab3a398 /build/plugins | |
parent | 7f5a9f394dbd9ac290cabbb7977538656b3a541e (diff) | |
parent | f7c04b5876af3d16849ab5e3079c0eabbd4e3a00 (diff) | |
download | ydb-42701242eaf5be980cb935631586d0e90b82641c.tar.gz |
Merge pull request #12554 from vitalyisaev2/YQ-3839.with_rightlib.3
Import from Arcadia + YDB FQ: turning gateways_config.proto into a file without external dependencies
Diffstat (limited to 'build/plugins')
-rw-r--r-- | build/plugins/_dart_fields.py | 90 | ||||
-rw-r--r-- | build/plugins/lib/nots/package_manager/base/package_json.py | 13 | ||||
-rw-r--r-- | build/plugins/ytest.py | 1 |
3 files changed, 62 insertions, 42 deletions
diff --git a/build/plugins/_dart_fields.py b/build/plugins/_dart_fields.py index eb5a0baa75..d7d0fa5737 100644 --- a/build/plugins/_dart_fields.py +++ b/build/plugins/_dart_fields.py @@ -571,13 +571,52 @@ class Linter: class LintConfigs: KEY = 'LINT-CONFIGS' + @staticmethod + def _from_config_type(unit, spec_args): + if not spec_args.get('CONFIG_TYPE') or not spec_args.get('CONFIG_TYPE')[0]: + return + linter_name = spec_args['NAME'][0] + config_type = spec_args.get('CONFIG_TYPE')[0] + if config_type not in consts.LINTER_CONFIG_TYPES[linter_name]: + message = "Unknown {} linter config type: {}. Allowed types: {}".format( + linter_name, config_type, ', '.join(consts.LINTER_CONFIG_TYPES[linter_name]) + ) + ymake.report_configure_error(message) + raise DartValueError() + if common_configs_dir := unit.get('MODULE_COMMON_CONFIGS_DIR'): + config = os.path.join(common_configs_dir, config_type) + path = unit.resolve(config) + if os.path.exists(path): + return _common.strip_roots(config) + message = "File not found: {}".format(path) + ymake.report_configure_error(message) + raise DartValueError() + else: + message = "Config type specifier is only allowed with autoincludes" + ymake.report_configure_error(message) + raise DartValueError() + @classmethod def python_configs(cls, unit, flat_args, spec_args): resolved_configs = [] - project_to_config_map = spec_args.get('PROJECT_TO_CONFIG_MAP', []) - if project_to_config_map: - # ruff, TODO rewrite once custom configs migrated to autoincludes scheme + if (custom_config := spec_args.get('CUSTOM_CONFIG')) and '/' in custom_config[0]: + # black if custom config is passed. + # XXX During migration we want to use the same macro parameter + # for path to linter config and config type + # thus, we check if '/' is present, if it is then it's a path + # TODO delete once custom configs migrated to autoincludes scheme + custom_config = custom_config[0] + assert_file_exists(unit, custom_config) + resolved_configs.append(custom_config) + return {cls.KEY: serialize_list(resolved_configs)} + + if config := cls._from_config_type(unit, spec_args): + # specified by config type, autoincludes scheme + return {cls.KEY: serialize_list([config])} + + if project_to_config_map := spec_args.get('PROJECT_TO_CONFIG_MAP'): + # ruff, TODO delete once custom configs migrated to autoincludes scheme project_to_config_map = project_to_config_map[0] assert_file_exists(unit, project_to_config_map) resolved_configs.append(project_to_config_map) @@ -587,23 +626,14 @@ class LintConfigs: resolved_configs.append(c) return {cls.KEY: serialize_list(resolved_configs)} - custom_config = spec_args.get('CUSTOM_CONFIG', []) - if custom_config: - # black if custom config is passed - # TODO rewrite once custom configs migrated to autoincludes scheme - custom_config = custom_config[0] - assert_file_exists(unit, custom_config) - resolved_configs.append(custom_config) - return {cls.KEY: serialize_list(resolved_configs)} - + # default config + linter_name = spec_args['NAME'][0] config = spec_args['CONFIGS'][0] - # black without custom config or flake8, using default configs file assert_file_exists(unit, config) - name = spec_args['NAME'][0] - cfg = get_linter_configs(unit, config)[name] + cfg = get_linter_configs(unit, config)[linter_name] assert_file_exists(unit, cfg) resolved_configs.append(cfg) - if name in ('flake8', 'py2_flake8'): + if linter_name in ('flake8', 'py2_flake8'): resolved_configs.extend(spec_args.get('FLAKE_MIGRATIONS_CONFIG', [])) return {cls.KEY: serialize_list(resolved_configs)} @@ -615,29 +645,13 @@ class LintConfigs: config = custom_config[0] assert_file_exists(unit, config) return {cls.KEY: serialize_list([config])} - linter_name = spec_args['NAME'][0] - if config_type := spec_args.get('CONFIG_TYPE'): - config_type = config_type[0] - if config_type not in consts.LINTER_CONFIG_TYPES[linter_name]: - message = "Unknown CPP linter config type: {}. Allowed types: {}".format( - config_type, ', '.join(consts.LINTER_CONFIG_TYPES[linter_name]) - ) - ymake.report_configure_error(message) - raise DartValueError() - if common_configs_dir := unit.get('MODULE_COMMON_CONFIGS_DIR'): - config = os.path.join(common_configs_dir, config_type) - path = unit.resolve(config) - if os.path.exists(path): - config = _common.strip_roots(config) - return {cls.KEY: serialize_list([config])} - message = "File not found: {}".format(path) - ymake.report_configure_error(message) - raise DartValueError() - else: - message = "Config type specifier is only allowed with autoincludes" - ymake.report_configure_error(message) - raise DartValueError() + + if config := cls._from_config_type(unit, spec_args): + # specified by config type, autoincludes scheme + return {cls.KEY: serialize_list([config])} + # default config + linter_name = spec_args['NAME'][0] config = spec_args.get('CONFIGS')[0] assert_file_exists(unit, config) config = get_linter_configs(unit, config)[linter_name] diff --git a/build/plugins/lib/nots/package_manager/base/package_json.py b/build/plugins/lib/nots/package_manager/base/package_json.py index 4fcb22e3ca..3840657992 100644 --- a/build/plugins/lib/nots/package_manager/base/package_json.py +++ b/build/plugins/lib/nots/package_manager/base/package_json.py @@ -1,9 +1,9 @@ import json +import logging import os from six import iteritems -import logging from .utils import build_pj_path @@ -19,7 +19,8 @@ class PackageJson(object): DEV_DEP_KEY = "devDependencies" PEER_DEP_KEY = "peerDependencies" OPT_DEP_KEY = "optionalDependencies" - DEP_KEYS = (DEP_KEY, DEV_DEP_KEY, PEER_DEP_KEY, OPT_DEP_KEY) + PNPM_OVERRIDES_KEY = "pnpm.overrides" + DEP_KEYS = (DEP_KEY, DEV_DEP_KEY, PEER_DEP_KEY, OPT_DEP_KEY, PNPM_OVERRIDES_KEY) WORKSPACE_SCHEMA = "workspace:" @@ -93,12 +94,16 @@ class PackageJson(object): def dependencies_iter(self): for key in self.DEP_KEYS: - deps = self.data.get(key) + if key == self.PNPM_OVERRIDES_KEY: + deps = self.data.get("pnpm", {}).get("overrides", {}) + else: + deps = self.data.get(key) + if not deps: continue for name, spec in iteritems(deps): - yield (name, spec) + yield name, spec def has_dependencies(self): first_dep = next(self.dependencies_iter(), None) diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py index dd540baf82..a8ef930a07 100644 --- a/build/plugins/ytest.py +++ b/build/plugins/ytest.py @@ -1061,6 +1061,7 @@ def on_add_py_linter_check(fields, unit, *args): "PROJECT_TO_CONFIG_MAP": 1, "FLAKE_MIGRATIONS_CONFIG": 1, "CUSTOM_CONFIG": 1, + "CONFIG_TYPE": 1, } _, spec_args = _common.sort_by_keywords(keywords, args) |