diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6519a849852fc..0f1caa607d663 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,3 +20,7 @@ repos: - id: mypy files: sklearn/ additional_dependencies: [pytest==6.2.4] +- repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8143cb7e04452..6a694bf1ba9d5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,11 +34,14 @@ jobs: versionSpec: '3.9' - bash: | # Include pytest compatibility with mypy - pip install pytest flake8 mypy==0.782 black==22.3.0 + pip install pytest flake8 mypy==0.782 black==22.3.0 isort displayName: Install linters - bash: | black --check --diff . displayName: Run black + - bash: | + isort --check --diff . + displayName: Run isort - bash: | ./build_tools/circle/linting.sh displayName: Run linting diff --git a/pyproject.toml b/pyproject.toml index 9b38a78966358..ce4a37113e528 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,6 @@ exclude = ''' | asv_benchmarks/env )/ ''' + +[tool.isort] +profile = "black" diff --git a/sklearn/model_selection/_split.py b/sklearn/model_selection/_split.py index d2a0b5e1fc329..d08eeba021537 100644 --- a/sklearn/model_selection/_split.py +++ b/sklearn/model_selection/_split.py @@ -18,10 +18,10 @@ from math import ceil, floor import numbers from abc import ABCMeta, abstractmethod -from inspect import signature -import numpy as np from scipy.special import comb +import numpy as np +from inspect import signature from ..utils import indexable, check_random_state, _safe_indexing from ..utils import _approximate_mode