MCPcopy Create free account
hub / github.com/catboost/catboost / main

Function main

tools/ruff_linter/wrapper.py:97–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95
96
97def main():
98 params = linter_params.get_params()
99
100 style_config_path = Path(params.configs[0])
101
102 # TODO: Ideally, to enable `extend` we first should move execution to build root (src files + configs)
103 # otherwise we risk allowing to steal from arcadia. To do that we need to mark modules 1st-party/3rd-party
104 # in pyproject.toml.
105 # UPD: it turned out to be more complicated for uservices-like projects because they use TOP_LEVEL / NAMESPACES
106 extend_option_present = check_extend_option_present(style_config_path)
107
108 ruff_bin = get_ruff_bin(params)
109
110 report = reporter.LintReport()
111 for file_name in params.files:
112 start_time = time.perf_counter()
113
114 if extend_option_present:
115 elapsed = time.perf_counter() - start_time
116 report.add(
117 file_name,
118 reporter.LintStatus.FAIL,
119 "`extend` option in not supported in ruff config files for now. Modify your configs not to have it.",
120 elapsed=elapsed,
121 )
122 continue
123
124 skip_reason = rules.get_skip_reason(file_name, Path(file_name).read_text(), skip_links=False)
125 if skip_reason:
126 elapsed = time.perf_counter() - start_time
127 report.add(
128 file_name,
129 reporter.LintStatus.SKIPPED,
130 f"Style check is omitted: {skip_reason}",
131 elapsed=elapsed,
132 )
133 continue
134
135 error = process_file(
136 file_name,
137 ruff_bin,
138 style_config_path,
139 params.source_root,
140 params.extra_params.get('check_format') == 'yes',
141 params.extra_params.get('run_in_source_root') == 'yes',
142 )
143 elapsed = time.perf_counter() - start_time
144
145 if error:
146 rel_file_name = os.path.relpath(file_name, params.source_root)
147 message = f'Run [[imp]]ya style --ruff {rel_file_name}[[rst]] to fix format\n{error}'
148 status = reporter.LintStatus.FAIL
149 else:
150 message = ''
151 status = reporter.LintStatus.GOOD
152 report.add(file_name, status, message, elapsed=elapsed)
153
154 report.dump(params.report_file)

Callers 1

wrapper.pyFile · 0.70

Calls 8

get_ruff_binFunction · 0.85
read_textMethod · 0.80
process_fileFunction · 0.70
get_paramsMethod · 0.45
addMethod · 0.45
getMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected