Skip to content

Commit

Permalink
lint: switch Black to ruff-format (#230)
Browse files Browse the repository at this point in the history
* lint: switch Black to `ruff-format`

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Borda and pre-commit-ci[bot] authored Feb 20, 2024
1 parent acc8733 commit b0d8bf7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 25 deletions.
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ repos:
additional_dependencies: [tomli]
args: ["--in-place"]

- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
name: Black code

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand Down Expand Up @@ -79,5 +73,7 @@ repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
hooks:
- id: ruff-format
args: ["--preview"]
- id: ruff
args: ["--fix"]
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ wrap-descriptions = 120
blank = true


[tool.black]
# https://github.com/psf/black
line-length = 120
exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)"


[tool.mypy]
files = [
"src/lightning_utilities",
Expand Down
1 change: 1 addition & 0 deletions scripts/adjust-torch-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
"""Adjusting version across PTorch ecosystem."""

import logging
import os
import re
Expand Down
12 changes: 5 additions & 7 deletions src/lightning_utilities/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

def main() -> None:
"""CLI entry point."""
fire.Fire(
{
"requirements": {
"prune-pkgs": prune_pkgs_in_requirements,
"set-oldest": replace_oldest_ver,
}
fire.Fire({
"requirements": {
"prune-pkgs": prune_pkgs_in_requirements,
"set-oldest": replace_oldest_ver,
}
)
})


if __name__ == "__main__":
Expand Down
10 changes: 4 additions & 6 deletions src/lightning_utilities/core/apply_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,10 @@ def apply_to_collections(
if isinstance(data1, Mapping) and data2 is not None:
# use union because we want to fail if a key does not exist in both
zipped = {k: (data1[k], data2[k]) for k in data1.keys() | data2.keys()}
return elem_type(
{
k: apply_to_collections(*v, dtype, function, *args, wrong_dtype=wrong_dtype, **kwargs)
for k, v in zipped.items()
}
)
return elem_type({
k: apply_to_collections(*v, dtype, function, *args, wrong_dtype=wrong_dtype, **kwargs)
for k, v in zipped.items()
})

is_namedtuple_ = is_namedtuple(data1)
is_sequence = isinstance(data1, Sequence) and not isinstance(data1, str)
Expand Down
1 change: 1 addition & 0 deletions src/lightning_utilities/core/rank_zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
"""Utilities that can be used for calling functions on a particular rank."""

import logging
import warnings
from functools import wraps
Expand Down

0 comments on commit b0d8bf7

Please # to comment.