Skip to content

Commit 191b53d

Browse files
[ruff] isort (#3294)
### Changes Use ruff isort instead of direct isort
1 parent 9bd8ddf commit 191b53d

File tree

7 files changed

+19
-27
lines changed

7 files changed

+19
-27
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ repos:
1414
- id: black
1515
files: '^.*\.py'
1616

17-
- repo: https://github.com/pycqa/isort
18-
rev: 5.13.0
19-
hooks:
20-
- id: isort
21-
name: isort (python)
22-
2317
- repo: https://github.com/igorshubovych/markdownlint-cli
2418
rev: v0.43.0
2519
hooks:

docs/styleguide/PyGuide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ the [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/pep-0
6161
## 2 Automating Code Formatting
6262

6363
To maintain consistency and readability throughout the codebase, we use the [black](https://github.com/psf/black)
64-
and [isort](https://github.com/PyCQA/isort) tools for formatting. Before committing any changes,
64+
and [ruff](https://docs.astral.sh/ruff/) tools for formatting. Before committing any changes,
6565
it's important to run a pre-commit command to ensure that the code is properly formatted.
6666
You can use the following commands for this:
6767

6868
```bash
6969
make pre-commit
7070
```
7171

72-
Also recommend configuring your IDE to run Black and isort tools automatically when saving files.
72+
Also recommend configuring your IDE to run Black and Ruff tools automatically when saving files.
7373

7474
Automatic code formatting is mandatory for all Python files, but you can disable it for specific cases if required:
7575

examples/post_training_quantization/torch/ssd300_vgg16/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
11-
11+
# isort: off
1212
import re
1313
import subprocess
1414
from pathlib import Path

nncf/experimental/torch/nas/bootstrapNAS/elasticity/multi_elasticity_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
# limitations under the License.
1111
import inspect
1212
from collections import OrderedDict
13-
from typing import Any, Dict, List, Optional
13+
from typing import Any, Dict, List, Optional, Tuple
1414
from typing import OrderedDict as OrderedDictType
15-
from typing import Tuple
1615

1716
from nncf.common.logging import nncf_logger
1817
from nncf.common.pruning.weights_flops_calculator import WeightsFlopsCalculator

pyproject.toml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ line-length = 120
7878
[tool.md_dead_link_check]
7979
exclude_files = ["ReleaseNotes.md"]
8080

81-
[tool.isort]
82-
line_length = 120
83-
force_single_line = true
84-
profile = "black"
85-
single_line_exclusions = "typing"
86-
skip_glob = "examples/post_training_quantization/torch/ssd300_vgg16/main.py"
87-
known_third_party = "datasets"
88-
8981
[tool.mypy]
9082
follow_imports = "silent"
9183
strict = true
@@ -153,15 +145,16 @@ ignore = [
153145
"D417", # undocumented-param
154146
]
155147
select = [
156-
"E", # pycodestyle rules
157-
"F", # pyflakes rules
158148
"CPY001", # copyright check
159-
"NPY", # numpy rules
160-
"UP", # pyupgrade
149+
"D", # pydocstyle
150+
"E", # pycodestyle rules
161151
"EM", # flake8-errmsg
152+
"F", # pyflakes rules
153+
"I", # isort
162154
"INP", # flake8-no-pep420
163155
"ISC", # flake8-implicit-str-concat
164-
"D", # pydocstyle
156+
"NPY", # numpy rules
157+
"UP", # pyupgrade
165158
]
166159
extend-select = [
167160
"SIM", # https://pypi.org/project/flake8-simplify
@@ -189,6 +182,11 @@ notice-rgx = """\
189182
# limitations under the License.
190183
"""
191184

185+
[tool.ruff.lint.isort]
186+
force-single-line = true
187+
known-third-party = ["datasets"]
188+
single-line-exclusions = ["typing"]
189+
192190
[tool.pytest.ini_options]
193191
pythonpath = "."
194192

tests/cross_fw/sdl/fuzz/quantize_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
from tests.cross_fw.shared.paths import TEST_ROOT
1515

1616
with atheris.instrument_imports():
17-
import nncf
1817
import sys
1918

19+
import nncf
20+
2021
from random import randint
2122
from random import seed
2223

tests/torch2/function_hook/quantization/test_quantized_graphs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
from tests.cross_fw.test_templates.helpers import RoPEModel
2525
from tests.cross_fw.test_templates.helpers import ScaledDotProductAttentionModel
2626
from tests.torch import test_models
27-
from tests.torch2.utils import compare_with_reference_file
28-
from tests.torch2.utils import to_comparable_nx_graph
2927
from tests.torch.quantization.test_algo_quantization import SharedLayersModel
3028
from tests.torch.test_compressed_graph import ModelDesc
29+
from tests.torch2.utils import compare_with_reference_file
30+
from tests.torch2.utils import to_comparable_nx_graph
3131

3232
REF_DIR = TEST_ROOT / "torch2" / "data" / "quantization" / "test_quantized_graphs"
3333

0 commit comments

Comments
 (0)