8000 MNT replace flake8 with ruff (#26630) · REDVM/scikit-learn@41d8f4a · GitHub
[go: up one dir, main page]

Skip to content

Commit 41d8f4a

Browse files
adrinjalaliREDVM
authored andcommitted
MNT replace flake8 with ruff (scikit-learn#26630)
1 parent b5cfa2d commit 41d8f4a

File tree

14 files changed

+70
-86
lines changed

14 files changed

+70
-86
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
command: |
1212
source build_tools/shared.sh
1313
# Include pytest compatibility with mypy
14-
pip install pytest flake8 $(get_dep mypy min) $(get_dep black min) cython-lint
14+
pip install pytest ruff $(get_dep mypy min) $(get_dep black min) cython-lint
1515
- run:
1616
name: linting
1717
command: ./build_tools/linting.sh

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
source build_tools/shared.sh
3131
# Include pytest compatibility with mypy
32-
pip install pytest flake8 $(get_dep mypy min) $(get_dep black min) cython-lint
32+
pip install pytest ruff $(get_dep mypy min) $(get_dep black min) cython-lint
3333
3434
- name: Run linting
3535
run: ./build_tools/linting.sh &> /tmp/linting_output.txt

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ repos:
99
rev: 23.3.0
1010
hooks:
1111
- id: black
12-
- repo: https://github.com/pycqa/flake8
13-
rev: 4.0.1
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.0.272
1415
hooks:
15-
- id: flake8
16-
types: [file, python]
16+
- id: ruff
1717
- repo: https://github.com/pre-commit/mirrors-mypy
1818
rev: v0.961
1919
hooks:

Makefile

Li 67E6 nes changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,4 @@ doc-noplot: inplace
6161
$(MAKE) -C doc html-noplot
6262

6363
code-analysis:
64-
flake8 sklearn | grep -v __init__ | grep -v external
65-
pylint -E -i y sklearn/ -d E1103,E0611,E1101
64+
build_tools/linting.sh

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- bash: |
3636
source build_tools/shared.sh
3737
# Include pytest compatibility with mypy
38-
pip install pytest flake8 $(get_dep mypy min) $(get_dep black min) cython-lint
38+
pip install pytest ruff $(get_dep mypy min) $(get_dep black min) cython-lint
3939
displayName: Install linters
4040
- bash: |
4141
./build_tools/linting.sh

build_tools/get_comment.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ def get_message(log_file, repo, run_id, details):
6868
"`black` detected issues. Please run `black .` locally and push "
6969
"the changes. Here you can see the detected issues. Note that "
7070
"running black might also fix some of the issues which might be "
71-
"detected by `flake8`."
71+
"detected by `ruff`."
7272
),
7373
details=details,
7474
)
7575

76-
# flake8
76+
# ruff
7777
message += get_step_message(
7878
log,
79-
start="### Running flake8 ###",
80-
end="Problems detected by flake8",
81-
title="`flake8`",
79+
start="### Running ruff ###",
80+
end="Problems detected by ruff",
81+
title="`ruff`",
8282
message=(
83-
"`flake8` detected issues. Please fix them locally and push the changes. "
83+
"`ruff` detected issues. Please run `ruff --fix --show-source .` "
84+
"locally, fix the remaining issues, and push the changes. "
8485
"Here you can see the detected issues."
8586
),
8687
details=details,

build_tools/linting.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ else
2222
global_status=1
2323
fi
2424

25-
echo -e "### Running flake8 ###\n"
26-
flake8 --show-source .
25+
echo -e "### Running ruff ###\n"
26+
ruff check --show-source .
2727
status=$?
2828
if [[ $status -eq 0 ]]
2929
then
30-
echo -e "No problem detected by flake8\n"
30+
echo -e "No problem detected by ruff\n"
3131
else
32-
echo -e "Problems detected by flake8, please fix them\n"
32+
echo -e "Problems detected by ruff, please fix them\n"
3333
global_status=1
3434
fi
3535

doc/developers/contributing.rst

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ how to set up your git repository:
254254

255255
.. prompt:: bash $
256256

257-
pip install pytest pytest-cov flake8 mypy numpydoc black==23.3.0
257+
pip install pytest pytest-cov ruff mypy numpydoc black==23.3.0
258258

259259
.. _upstream:
260260

@@ -425,30 +425,15 @@ complies with the following rules before marking a PR as ``[MRG]``. The
425425
non-regression tests should fail for the code base in the ``main`` branch
426426
and pass for the PR code.
427427

428-
5. Run `black` to auto-format your code.
429428

430-
.. prompt:: bash $
431-
432-
black .
433-
434-
See black's
435-
`editor integration documentation <https://black.readthedocs.io/en/stable/integrations/editors.html>`_
436-
to configure your editor to run `black`.
437-
438-
6. Run `flake8` to make sure you followed the project coding conventions.
439-
440-
.. prompt:: bash $
441-
442-
flake8 .
443-
444-
7. Follow the :ref:`coding-guidelines`.
429+
5. Follow the :ref:`coding-guidelines`.
445430

446431

447-
8. When applicable, use the validation tools and scripts in the
432+
6. When applicable, use the validation tools and scripts in the
448433
``sklearn.utils`` submodule. A list of utility routines available
449434
for developers can be found in the :ref:`developers-utils` page.
450435

451-
9. Often pull requests resolve one or more other issues (or pull requests).
436+
7. Often pull requests resolve one or more other issues (or pull requests).
452437
If merging your pull request means that some other issues/PRs should
453438
be closed, you should `use keywords to create link to them
454439
<https://github.com/blog/1506-closing-issues-via-pull-requests/>`_
@@ -458,7 +443,7 @@ complies with the following rules before marking a PR as ``[MRG]``. The
458443
related to some other issues/PRs, create a link to them without using
459444
the keywords (e.g., ``See also #1234``).
460445

461-
10. PRs should often substantiate the change, through benchmarks of
446+
8. PRs should often substantiate the change, through benchmarks of
462447
performance and efficiency (see :ref:`monitoring_performances`) or through
463448
examples of usage. Examples also illustrate the features and intricacies of
464449
the library to users. Have a look at other examples in the `examples/
@@ -467,14 +452,14 @@ complies with the following rules before marking a PR as ``[MRG]``. The
467452
functionality is useful in practice and, if possible, compare it to other
468453
methods available in scikit-learn.
469454

470-
11. New features have some maintenance overhead. We expect PR authors
455+
9. New features have some maintenance overhead. We expect PR authors
471456
to take part in the maintenance for the code they submit, at least
472457
initially. New features need to be illustrated with narrative
473458
documentation in the user guide, with small code snippets.
474459
If relevant, please also add references in the literature, with PDF links
475460
when possible.
476461

477-
12. The user guide should also include expected time and space complexity
462+
10. The user guide should also include expected time and space complexity
478463
of the algorithm and scalability, e.g. "this algorithm can scale to a
479464
large number of samples > 100000, but does not scale in dimensionality:
480465
n_features is expected to be lower than 100".
@@ -534,8 +519,10 @@ Continuous Integration (CI)
534519

535520
* Azure pipelines are used for testing scikit-learn on Linux, Mac and Windows,
536521
with different dependencies and settings.
537-
* CircleCI is used to build the docs for viewing, for linting with flake8, and
538-
for testing with ARM64 / aarch64 on Linux
522+
* CircleCI is used to build the docs for viewing.
523+
* Github Actions are used for various tasks, including building wheels and
524+
source distributions.
525+
* Cirrus CI is used to build on ARM.
539526

540527
Please note that if one of the following markers appear in the latest commit
541528
message, the following actions are taken.

examples/feature_selection/plot_select_from_model_diabetes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# were already standardized.
4444
# For a more complete example on the interpretations of the coefficients of
4545
# linear models, you may refer to
46-
# :ref:`sphx_glr_auto_examples_inspection_plot_linear_model_coefficient_interpretation.py`.
46+
# :ref:`sphx_glr_auto_examples_inspection_plot_linear_model_coefficient_interpretation.py`. # noqa: E501
4747
import matplotlib.pyplot as plt
4848
import numpy as np
4949
from sklearn.linear_model import RidgeCV

examples/text/plot_document_classification_20newsgroups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def benchmark(clf, custom_name=False):
358358
# Notice that the most important hyperparameters values were tuned using a grid
359359
# search procedure not shown in this notebook for the sake of simplicity. See
360360
# the example script
361-
# :ref:`sphx_glr_auto_examples_model_selection_plot_grid_search_text_feature_extraction.py`
361+
# :ref:`sphx_glr_auto_examples_model_selection_plot_grid_search_text_feature_extraction.py` # noqa: E501
362362
# for a demo on how such tuning can be done.
363363

364364
from sklearn.linear_model import LogisticRegression

0 commit comments

Comments
 (0)
0