Skip to content

Commit

Permalink
deps(isort): replace isort with ruff check --select=I
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Dec 15, 2024
1 parent 92428dd commit e81958d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 30 deletions.
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ flake8-install:

.PHONY: py-format-install
py-format-install:
$(call check_pip_install,isort)
$(call check_pip_install,black)
$(call check_pip_install,ruff)

.PHONY: ruff-install
ruff-install:
Expand Down Expand Up @@ -156,10 +156,10 @@ flake8: flake8-install

.PHONY: py-format
py-format: py-format-install
$(PYTHON) -m isort --version
$(PYTHON) -m black --version
$(PYTHON) -m isort --project $(PROJECT_PATH) --check $(PYTHON_FILES) && \
$(PYTHON) -m black --check $(PYTHON_FILES)
$(PYTHON) -m ruff --version
$(PYTHON) -m black --check $(PYTHON_FILES) && \
$(PYTHON) -m ruff check --select=I $(PYTHON_FILES)

.PHONY: ruff
ruff: ruff-install
Expand Down Expand Up @@ -252,7 +252,6 @@ lint: ruff flake8 py-format mypy pylint doctest clang-format clang-tidy cpplint

.PHONY: format
format: py-format-install ruff-install clang-format-install addlicense-install
$(PYTHON) -m isort --project $(PROJECT_PATH) $(PYTHON_FILES)
$(PYTHON) -m black $(PYTHON_FILES)
$(PYTHON) -m ruff check --fix --exit-zero .
$(CLANG_FORMAT) -style=file -i $(CXX_FILES)
Expand Down
1 change: 0 additions & 1 deletion conda-recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ dependencies:
- conda-forge::pytest
- conda-forge::pytest-cov
- conda-forge::pytest-xdist
- conda-forge::isort
- conda-forge::black
- conda-forge::pylint
- conda-forge::mypy
Expand Down
6 changes: 4 additions & 2 deletions optree/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import functools
from typing import TYPE_CHECKING, Any, Callable, ClassVar
from typing_extensions import Self # Python 3.11+
from typing_extensions import deprecated # Python 3.13+
from typing_extensions import (
Self, # Python 3.11+
deprecated, # Python 3.13+
)

from optree import registry
from optree.accessor import GetAttrEntry
Expand Down
6 changes: 4 additions & 2 deletions optree/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
TypeVar,
overload,
)
from typing_extensions import TypeAlias # Python 3.10+
from typing_extensions import deprecated # Python 3.13+
from typing_extensions import (
TypeAlias, # Python 3.10+
deprecated, # Python 3.13+
)

from optree import _C
from optree.accessor import (
Expand Down
10 changes: 6 additions & 4 deletions optree/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
ValuesView,
runtime_checkable,
)
from typing_extensions import NamedTuple # Generic NamedTuple: Python 3.11+
from typing_extensions import ParamSpec # Python 3.10+
from typing_extensions import Self # Python 3.11+
from typing_extensions import TypeAlias # Python 3.10+
from typing_extensions import (
NamedTuple, # Generic NamedTuple: Python 3.11+
ParamSpec, # Python 3.10+
Self, # Python 3.11+
TypeAlias, # Python 3.10+
)

from optree import _C
from optree._C import PyTreeKind, PyTreeSpec
Expand Down
18 changes: 7 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jax = ["jax"]
numpy = ["numpy"]
torch = ["torch"]
lint = [
"isort",
"black",
"pylint[spelling]",
"mypy",
Expand Down Expand Up @@ -124,16 +123,6 @@ line-length = 100
skip-string-normalization = true
target-version = ["py38"]

[tool.isort]
atomic = true
profile = "black"
src_paths = ["optree", "tests"]
extra_standard_library = ["typing_extensions"]
indent = 4
line_length = 100
lines_after_imports = 2
multi_line_output = 3

[tool.mypy]
python_version = "3.8"
exclude = ["^setup\\.py$", "^tests/.*\\.py$"]
Expand Down Expand Up @@ -186,6 +175,7 @@ src = ["optree", "tests"]
select = [
"E", "W", # pycodestyle
"F", # pyflakes
"I", # isort
"C90", # mccabe
"N", # pep8-naming
"UP", # pyupgrade
Expand Down Expand Up @@ -272,6 +262,12 @@ typing-modules = ["optree.typing"]
"ANN", # flake8-annotations
]

[tool.ruff.lint.isort]
known-first-party = ["optree"]
known-local-folder = ["optree", "tests"]
extra-standard-library = ["typing_extensions"]
lines-after-imports = 2

[tool.ruff.lint.pydocstyle]
convention = "google"

Expand Down
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pytest
pytest-cov
pytest-xdist
isort
black
pylint[spelling]
mypy
Expand Down

0 comments on commit e81958d

Please sign in to comment.