Skip to content

Commit

Permalink
refactor: Switch to ruff for formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
elenakrittik committed Mar 29, 2024
1 parent 2919c61 commit c2f9e2c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .libcst.codemod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ generated_code_marker: '@generated_module'
# Command line and arguments for invoking a code formatter. Anything
# specified here must be capable of taking code via stdin and returning
# formatted code via stdout.
formatter: ['black', '-q' , '-']
formatter: ['ruff', 'format' , '-']
# List of regex patterns which LibCST will evaluate against filenames to
# determine if the module should be touched.
blacklist_patterns: []
Expand Down
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ 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/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
name: "run black in all files"

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: ruff
args: [--fix, --fixable=I]
- id: ruff-format
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/) (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.
Other tools used in this project include [ruff](https://beta.ruff.rs/docs/) (linter and formatter), 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
8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ changelog = [
codemod = [
# run codemods on the respository (mostly automated typing)
"libcst~=1.1.0",
"black==23.9.1",
"ruff==0.3.4",
"autotyping==23.2.0",
]
typing = [
Expand All @@ -104,7 +104,6 @@ build = [
]

[tool.pdm.scripts]
black = { composite = ["lint black"], help = "Run black" }
docs = { cmd = "nox -Rs docs --", help = "Build the documentation for development" }
lint = { cmd = "nox -Rs lint --", help = "Check all files for linting errors" }
pyright = { cmd = "nox -Rs pyright --", help = "Run pyright" }
Expand All @@ -114,7 +113,6 @@ test = { cmd = "nox -Rs test --", help = "Run pytest" }

# legacy tasks for those who still type `task`
[tool.taskipy.tasks]
black = { cmd = "black", help = "Run black" }
docs = { cmd = "docs", help = "Build the documentation for development" }
lint = { cmd = "lint", help = "Check all files for linting errors" }
pyright = { cmd = "pyright", help = "Run pyright" }
Expand All @@ -124,10 +122,6 @@ test = { cmd = "test", help = "Run pytest" }
[tool.taskipy.settings]
runner = "pdm run"

[tool.black]
line-length = 100
target-version = ["py38", "py39", "py310", "py311", "py312"]

[tool.ruff]
line-length = 100
target-version = "py38"
Expand Down

0 comments on commit c2f9e2c

Please sign in to comment.