Skip to content

Commit 0438e75

Browse files
authored
Use ruff format (#370)
1 parent 411c793 commit 0438e75

File tree

7 files changed

+23
-30
lines changed

7 files changed

+23
-30
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.4.0
7+
rev: v4.5.0
88
hooks:
99
- id: check-case-conflict
1010
- id: check-ast
@@ -21,7 +21,7 @@ repos:
2121
- id: trailing-whitespace
2222

2323
- repo: https://github.com/python-jsonschema/check-jsonschema
24-
rev: 0.26.3
24+
rev: 0.27.0
2525
hooks:
2626
- id: check-github-workflows
2727

@@ -33,7 +33,7 @@ repos:
3333
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
3434

3535
- repo: https://github.com/pre-commit/mirrors-prettier
36-
rev: "v3.0.2"
36+
rev: "v3.0.3"
3737
hooks:
3838
- id: prettier
3939
types_or: [yaml, html, json]
@@ -44,16 +44,11 @@ repos:
4444
- id: blacken-docs
4545
additional_dependencies: [black==23.7.0]
4646

47-
- repo: https://github.com/psf/black-pre-commit-mirror
48-
rev: 23.7.0
49-
hooks:
50-
- id: black
51-
5247
- repo: https://github.com/codespell-project/codespell
53-
rev: "v2.2.5"
48+
rev: "v2.2.6"
5449
hooks:
5550
- id: codespell
56-
args: ["-L", "sur,nd"]
51+
args: ["-L", "re-use"]
5752

5853
- repo: https://github.com/pre-commit/pygrep-hooks
5954
rev: "v1.10.0"
@@ -63,13 +58,14 @@ repos:
6358
- id: rst-inline-touching-normal
6459

6560
- repo: https://github.com/astral-sh/ruff-pre-commit
66-
rev: v0.0.287
61+
rev: v0.1.3
6762
hooks:
6863
- id: ruff
6964
args: ["--fix", "--show-fixes"]
65+
- id: ruff-format
7066

7167
- repo: https://github.com/scientific-python/cookie
72-
rev: "2023.08.23"
68+
rev: "2023.10.27"
7369
hooks:
7470
- id: sp-repo-review
7571
additional_dependencies: ["repo-review[cli]"]

jupyter_core/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def migrate_config(self) -> None:
165165
"""Migrate config/data from IPython 3"""
166166
try: # let's see if we can open the marker file
167167
# for reading and updating (writing)
168-
f_marker = open(os.path.join(self.config_dir, "migrated"), 'r+') # noqa
168+
f_marker = open(os.path.join(self.config_dir, "migrated"), "r+") # noqa
169169
except PermissionError: # not readable and/or writable
170170
return # so let's give up migration in such an environment
171171
except FileNotFoundError: # cannot find the marker file

jupyter_core/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def _do_i_own(path: str) -> bool:
8383
except Exception: # noqa
8484
pass
8585

86-
if hasattr(os, 'geteuid'):
86+
if hasattr(os, "geteuid"):
8787
try:
8888
st = p.stat()
8989
return st.st_uid == os.geteuid()

pyproject.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ dependencies = ["mypy~=1.6.0", "traitlets>=5.11.2"]
9494
test = "mypy --install-types --non-interactive {args}"
9595

9696
[tool.hatch.envs.lint]
97-
dependencies = ["black==23.3.0", "mdformat>0.7", "ruff==0.0.281"]
97+
dependencies = ["mdformat>0.7", "ruff==0.1.3"]
9898
detached = true
9999
[tool.hatch.envs.lint.scripts]
100100
style = [
101101
"ruff {args:.}",
102-
"black --check --diff {args:.}",
102+
"ruff format {args:.}",
103103
"mdformat --check {args:*.md}"
104104
]
105105
fmt = [
106-
"black {args:.}",
107106
"ruff --fix {args:.}",
107+
"ruff format {args:.}",
108108
"mdformat {args:*.md}"
109109
]
110110

@@ -153,16 +153,13 @@ exclude_lines = [
153153
"@(abc\\.)?abstractmethod",
154154
]
155155

156-
[tool.black]
157-
line-length = 100
158-
skip-string-normalization = true
159-
target-version = ["py38"]
160-
161156
[tool.ruff]
162157
target-version = "py38"
163158
line-length = 100
159+
160+
[tool.ruff.lint]
164161
select = [
165-
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "ISC", "N",
162+
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "N",
166163
"PLC", "PLE", "PLR", "PLW", "Q", "RUF", "S", "SIM", "T", "TID", "UP",
167164
"W", "YTT",
168165
]
@@ -183,7 +180,7 @@ unfixable = [
183180
"RUF100",
184181
]
185182

186-
[tool.ruff.per-file-ignores]
183+
[tool.ruff.lint.per-file-ignores]
187184
# B011 Do not call assert False since python -O removes these calls
188185
# F841 local variable 'foo' is assigned to but never used
189186
# C408 Unnecessary `dict` call

tests/dotipython_empty/profile_default/ipython_nbconvert_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@
183183
# ------------------------------------------------------------------------------
184184

185185
# Exports to a Latex template. Inherit from this class if your template is
186-
# LaTeX based and you need custom tranformers/filters. Inherit from it if you
187-
# are writing your own HTML template and need custom tranformers/filters. If
188-
# you don't need custom tranformers/filters, just change the 'template_file'
186+
# LaTeX based and you need custom transformers/filters. Inherit from it if you
187+
# are writing your own HTML template and need custom transformers/filters. If
188+
# you don't need custom transformers/filters, just change the 'template_file'
189189
# config option. Place your template in the special "/latex" subfolder of the
190190
# "../templates" folder.
191191

tests/test_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def write_executable(path, source):
6464
try:
6565
import importlib.resources
6666

67-
if not hasattr(importlib.resources, 'files'):
67+
if not hasattr(importlib.resources, "files"):
6868
raise ImportError
69-
wp = importlib.resources.files('setuptools').joinpath('cli-32.exe')
69+
wp = importlib.resources.files("setuptools").joinpath("cli-32.exe")
7070
w = wp.read_bytes()
7171
except (ImportError, FileNotFoundError, SystemError):
7272
pytest.skip(

tests/test_migrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def env(request):
5454
def fin():
5555
"""Cleanup test env"""
5656
env_patch.stop()
57-
shutil.rmtree(td, ignore_errors=os.name == 'nt')
57+
shutil.rmtree(td, ignore_errors=os.name == "nt")
5858

5959
request.addfinalizer(fin)
6060

0 commit comments

Comments
 (0)