diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd3b5a95..f72a7cce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,12 +43,14 @@ jobs: strategy: matrix: python-version: ${{ fromJSON(needs.Envvars.outputs.version_matrix) }} - task: [Typecheck, Lint, Yapf, Test] + task: [Typecheck, Lint, Ruff, Yapf, Test] include: - task: Typecheck cmd: pytype -j auto . - task: Lint cmd: pylint --rcfile .pylintrc --recursive yes . + - task: Ruff + cmd: pipx run ruff==0.9.3 check - task: Yapf cmd: yapf . -drp - task: Test diff --git a/Pipfile b/Pipfile index 044b3d1e..1ce8f96d 100644 --- a/Pipfile +++ b/Pipfile @@ -15,9 +15,9 @@ dm-reverb = "==0.14.0" pylint = "==3.3.2" pytest = "==8.3.4" pytype = "==2024.10.11" +ruff = "==0.9.3" yapf = "==0.43.0" [ci] joblib = "==1.4.2" shap = "==0.46.0" - diff --git a/compiler_opt/es/blackbox_evaluator.py b/compiler_opt/es/blackbox_evaluator.py index 953a8152..35de7500 100644 --- a/compiler_opt/es/blackbox_evaluator.py +++ b/compiler_opt/es/blackbox_evaluator.py @@ -124,14 +124,12 @@ def __init__(self, train_corpus: corpus.Corpus, def get_results( self, pool: FixedWorkerPool, perturbations: List[policy_saver.Policy] ) -> List[concurrent.futures.Future]: - job_args = [] - for perturbation in perturbations: - job_args.append({ - 'modules': self._train_corpus.module_specs, - 'function_index_path': self._function_index_path, - 'bb_trace_path': self._bb_trace_path, - 'tflite_policy': perturbation - }) + job_args = [{ + 'modules': self._train_corpus.module_specs, + 'function_index_path': self._function_index_path, + 'bb_trace_path': self._bb_trace_path, + 'tflite_policy': perturbation + } for perturbation in perturbations] _, futures = buffered_scheduler.schedule_on_worker_pool( action=lambda w, args: w.compile_corpus_and_evaluate(**args), diff --git a/compiler_opt/es/blackbox_test_utils.py b/compiler_opt/es/blackbox_test_utils.py index 3a0a2ca4..404525e9 100644 --- a/compiler_opt/es/blackbox_test_utils.py +++ b/compiler_opt/es/blackbox_test_utils.py @@ -45,7 +45,7 @@ def compile(self, policy: policy_saver.Policy, class ESTraceWorker(worker.Worker): """Temporary placeholder worker. - + This is a test worker for TraceBlackboxEvaluator that expects a slightly different interface than other workers. """ diff --git a/pyproject.toml b/pyproject.toml index bdf58d2c..4fd17dba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,12 @@ -# DO always create a tracking issue when allow-listing warnings -# DO NOT disable warnings-as-error: warnings of today are tomorrow's evolvability blocker. +[tool.ruff] +line-length = 103 +lint.select = [ "C40", "C9", "E", "F", "PERF", "W" ] +lint.ignore = [ "E722", "E731", "E741", "F401", "PERF203" ] +lint.mccabe.max-complexity = 18 [tool.pytest.ini_options] +# DO always create a tracking issue when allow-listing warnings +# DO NOT disable warnings-as-error: warnings of today are tomorrow's evolvability blocker. filterwarnings = [ # Treat warnings as errors "error",