Skip to content

Commit

Permalink
refactor(tooling): Replace isort with ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
elenakrittik committed Mar 19, 2024
1 parent 8882c69 commit c007709
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 26 deletions.
12 changes: 0 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ repos:
exclude_types: [json, pofile]
exclude: 'changelog/|py.typed|disnake/bin/COPYING|.github/PULL_REQUEST_TEMPLATE.md|.github/CODEOWNERS|LICENSE|MANIFEST.in'

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--extend-skip", "examples"]
name: "run isort in all files"
exclude: ^examples/
- id: isort
args: ["--profile", "black", "--thirdparty", "disnake"]
name: "run isort in examples"
files: ^examples/

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Once PDM is installed, use the following command to initialize a virtual environ
$ pdm run setup_env
```

Other tools used in this project include [black](https://black.readthedocs.io/en/stable/) + [isort](https://pycqa.github.io/isort/) (formatters), [ruff](https://beta.ruff.rs/docs/) (linter), and [pyright](https://microsoft.github.io/pyright/#/) (type-checker). For the most part, these automatically run on every commit with no additional action required - see below for details.
Other tools used in this project include [black](https://black.readthedocs.io/en/stable/) (formatter), [ruff](https://beta.ruff.rs/docs/) (linter), and [pyright](https://microsoft.github.io/pyright/#/) (type-checker). For the most part, these automatically run on every commit with no additional action required - see below for details.

All of the following checks also automatically run for every PR on GitHub, so don't worry if you're not sure whether you missed anything. A PR cannot be merged as long as there are any failing checks.

Expand Down
3 changes: 2 additions & 1 deletion examples/basic_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import os
from typing import Any, Dict, Optional

import disnake
import youtube_dl # type: ignore

import disnake
from disnake.ext import commands

# Suppress noise about console usage from errors
Expand Down
4 changes: 2 additions & 2 deletions examples/interactions/injections.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from dataclasses import dataclass
from typing import Any, Literal, Optional

import disnake

# this file uses pytz in one of its examples but it is completely optional
import pytz

import disnake
from disnake.ext import commands

bot = commands.Bot(command_prefix=commands.when_mentioned)
Expand Down
15 changes: 5 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ build = [
[tool.pdm.scripts]
black = { composite = ["lint black"], help = "Run black" }
docs = { cmd = "nox -Rs docs --", help = "Build the documentation for development" }
isort = { composite = ["lint isort"], help = "Run isort" }
lint = { cmd = "nox -Rs lint --", help = "Check all files for linting errors" }
pyright = { cmd = "nox -Rs pyright --", help = "Run pyright" }
setup_env = { cmd = "pdm install -d -G speed -G docs -G voice", help = "Set up the local environment and all dependencies" }
Expand All @@ -117,7 +116,6 @@ test = { cmd = "nox -Rs test --", help = "Run pytest" }
[tool.taskipy.tasks]
black = { cmd = "black", help = "Run black" }
docs = { cmd = "docs", help = "Build the documentation for development" }
isort = { cmd = "isort", help = "Run isort" }
lint = { cmd = "lint", help = "Check all files for linting errors" }
pyright = { cmd = "pyright", help = "Run pyright" }
setup_env = { cmd = "setup_env", help = "Setup the local environment and set up all dependencies" }
Expand All @@ -130,13 +128,6 @@ runner = "pdm run"
line-length = 100
target-version = ["py38", "py39", "py310", "py311", "py312"]

[tool.isort]
profile = "black"
py_version = 38
line_length = 100
combine_as_imports = true
filter_files = true

[tool.ruff]
line-length = 100
target-version = "py38"
Expand Down Expand Up @@ -171,6 +162,7 @@ select = [
# "PLR", # pylint refactor
"PLW", # pylint warnings
"TRY002", "TRY004", "TRY201", # tryceratops
"I",
]
ignore = [
# star imports
Expand Down Expand Up @@ -202,7 +194,7 @@ ignore = [
# typevar names don't match variance (we don't always want this)
"PLC0105",

# import aliases are fixed by isort
# import aliases are fixed by ruff
"PLC0414",

# outer loop variables are overwritten by inner assignment target, these are mostly intentional
Expand Down Expand Up @@ -253,6 +245,9 @@ ignore = [
"examples/basic_voice.py" = ["S104"] # possible binding to all interfaces
"examples/views/tic_tac_toe.py" = ["E741"] # ambigious variable name: `O`

[tool.ruff.lint.isort]
combine-as-imports = true

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

Expand Down

0 comments on commit c007709

Please sign in to comment.