Skip to content

Commit

Permalink
Replace isort with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Quexington committed Oct 29, 2024
1 parent bc901da commit cbd9c69
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 35 deletions.
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ repos:
entry: ./activated.py mypy
language: system
pass_filenames: false
- repo: local
hooks:
- id: isort
name: isort
entry: ./activated.py isort
language: system
types: [python]
- repo: local
hooks:
- id: flake8
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ to configure how the tests are run. For example, for more logging: change the lo
```bash
sh install.sh -d
. ./activate
black . && isort benchmarks build_scripts chia tests tools *.py && mypy && flake8 benchmarks build_scripts chia tests tools *.py && pylint benchmarks build_scripts chia tests tools *.py
black . && ruff check --fix && mypy && flake8 benchmarks build_scripts chia tests tools *.py && pylint benchmarks build_scripts chia tests tools *.py
py.test tests -v --durations 0
```

The [black library](https://black.readthedocs.io/en/stable/) is used as an automatic style formatter to make things easier.
The [flake8 library](https://readthedocs.org/projects/flake8/) helps ensure consistent style.
The [Mypy library](https://mypy.readthedocs.io/en/stable/) is very useful for ensuring objects are of the correct type, so try to always add the type of the return value, and the type of local variables.
The [isort library](https://isort.readthedocs.io) is used to sort, group and validate imports in all python files.
The [Ruff library](https://docs.astral.sh) is used to further lint all of the python files
The [Ruff library](https://docs.astral.sh) is used to sort, group, validate imports, and further lint all of the python files

If you want verbose logging for tests, edit the `tests/pytest.ini` file.

Expand Down
3 changes: 1 addition & 2 deletions chia/_tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
from chia.full_node.full_node_api import FullNodeAPI
from chia.full_node.signage_point import SignagePoint
from chia.full_node.sync_store import Peak
from chia.protocols import full_node_protocol
from chia.protocols import full_node_protocol, timelord_protocol, wallet_protocol
from chia.protocols import full_node_protocol as fnp
from chia.protocols import timelord_protocol, wallet_protocol
from chia.protocols.full_node_protocol import RespondTransaction
from chia.protocols.protocol_message_types import ProtocolMessageTypes
from chia.protocols.shared_protocol import Capability, default_capabilities
Expand Down
11 changes: 9 additions & 2 deletions chia/full_node/mempool_check_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
import logging
from typing import Optional

from chia_rs import DONT_VALIDATE_SIGNATURE, MEMPOOL_MODE, G2Element, get_flags_for_height_and_constants
from chia_rs import (
DONT_VALIDATE_SIGNATURE,
MEMPOOL_MODE,
G2Element,
get_flags_for_height_and_constants,
run_block_generator,
run_block_generator2,
run_chia_program,
)
from chia_rs import get_puzzle_and_solution_for_coin2 as get_puzzle_and_solution_for_coin_rust
from chia_rs import run_block_generator, run_block_generator2, run_chia_program

from chia.consensus.constants import ConsensusConstants
from chia.consensus.cost_calculator import NPCResult
Expand Down
8 changes: 6 additions & 2 deletions chia/wallet/dao_wallet/dao_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
from chia.types.condition_opcodes import ConditionOpcode
from chia.util.ints import uint32, uint64, uint128
from chia.wallet import singleton
from chia.wallet.cat_wallet.cat_utils import CAT_MOD, SpendableCAT, construct_cat_puzzle
from chia.wallet.cat_wallet.cat_utils import (
CAT_MOD,
SpendableCAT,
construct_cat_puzzle,
unsigned_spend_bundle_for_spendable_cats,
)
from chia.wallet.cat_wallet.cat_utils import get_innerpuzzle_from_puzzle as get_innerpuzzle_from_cat_puzzle
from chia.wallet.cat_wallet.cat_utils import unsigned_spend_bundle_for_spendable_cats
from chia.wallet.cat_wallet.cat_wallet import CATWallet
from chia.wallet.cat_wallet.dao_cat_wallet import DAOCATWallet
from chia.wallet.coin_selection import select_coins
Expand Down
18 changes: 2 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ build = { version = "1.2.1", optional = true }
coverage = { version = "7.6.4", optional = true }
diff-cover = { version = "9.2.0", optional = true }
flake8 = { version = "7.1.1", optional = true }
isort = { version = "5.13.2", optional = true }
# TODO: but... keyrings_cryptfile goes 15 minutes without locking while this does in 75 seconds
"keyrings.cryptfile" = { version = "1.3.9", optional = true }
mypy = { version = "1.11.1", optional = true }
Expand All @@ -108,7 +107,7 @@ ruff = { version = "0.7.1", optional = true }


[tool.poetry.extras]
dev = ["aiohttp_cors", "black", "build", "coverage", "diff-cover", "flake8", "isort", "mypy", "pre-commit", "py3createtorrent", "pyinstaller", "pytest", "pytest-cov", "pytest-mock", "pytest-monitor", "pytest-xdist", "ruff", "types-aiofiles", "types-cryptography", "types-pyyaml", "types-setuptools", "pyupgrade", "lxml"]
dev = ["aiohttp_cors", "black", "build", "coverage", "diff-cover", "flake8", "mypy", "pre-commit", "py3createtorrent", "pyinstaller", "pytest", "pytest-cov", "pytest-mock", "pytest-monitor", "pytest-xdist", "ruff", "types-aiofiles", "types-cryptography", "types-pyyaml", "types-setuptools", "pyupgrade", "lxml"]
upnp = ["miniupnpc"]
legacy_keyring = ["keyrings.cryptfile"]

Expand Down Expand Up @@ -161,7 +160,7 @@ line-length = 120

[tool.ruff.lint]
preview = true
select = ["PL"]
select = ["PL", "I", "FA"]
explicit-preview-rules = false
ignore = [
# Pylint convention
Expand Down Expand Up @@ -206,6 +205,9 @@ ignore = [
"PLW0120", # useless-else-on-loop
]

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.pylint]
max-args = 5
max-locals = 15
Expand Down

0 comments on commit cbd9c69

Please sign in to comment.