Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ruff format #370

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-ast
Expand All @@ -21,7 +21,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
rev: 0.27.0
hooks:
- id: check-github-workflows

Expand All @@ -33,7 +33,7 @@ repos:
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.2"
rev: "v3.0.3"
hooks:
- id: prettier
types_or: [yaml, html, json]
Expand All @@ -44,16 +44,11 @@ repos:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.5"
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-L", "sur,nd"]
args: ["-L", "re-use"]

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

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.1.3
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/scientific-python/cookie
rev: "2023.08.23"
rev: "2023.10.27"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
2 changes: 1 addition & 1 deletion jupyter_core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def migrate_config(self) -> None:
"""Migrate config/data from IPython 3"""
try: # let's see if we can open the marker file
# for reading and updating (writing)
f_marker = open(os.path.join(self.config_dir, "migrated"), 'r+') # noqa
f_marker = open(os.path.join(self.config_dir, "migrated"), "r+") # noqa
except PermissionError: # not readable and/or writable
return # so let's give up migration in such an environment
except FileNotFoundError: # cannot find the marker file
Expand Down
2 changes: 1 addition & 1 deletion jupyter_core/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _do_i_own(path: str) -> bool:
except Exception: # noqa
pass

if hasattr(os, 'geteuid'):
if hasattr(os, "geteuid"):
try:
st = p.stat()
return st.st_uid == os.geteuid()
Expand Down
17 changes: 7 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ dependencies = ["mypy~=1.6.0", "traitlets>=5.11.2"]
test = "mypy --install-types --non-interactive {args}"

[tool.hatch.envs.lint]
dependencies = ["black==23.3.0", "mdformat>0.7", "ruff==0.0.281"]
dependencies = ["mdformat>0.7", "ruff==0.1.3"]
detached = true
[tool.hatch.envs.lint.scripts]
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
"ruff format {args:.}",
"mdformat --check {args:*.md}"
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"ruff format {args:.}",
"mdformat {args:*.md}"
]

Expand Down Expand Up @@ -152,16 +152,13 @@ exclude_lines = [
"@(abc\\.)?abstractmethod",
]

[tool.black]
line-length = 100
skip-string-normalization = true
target-version = ["py38"]

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

[tool.ruff.lint]
select = [
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "ISC", "N",
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "N",
"PLC", "PLE", "PLR", "PLW", "Q", "RUF", "S", "SIM", "T", "TID", "UP",
"W", "YTT",
]
Expand All @@ -182,7 +179,7 @@ unfixable = [
"RUF100",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# B011 Do not call assert False since python -O removes these calls
# F841 local variable 'foo' is assigned to but never used
# C408 Unnecessary `dict` call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@
# ------------------------------------------------------------------------------

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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def write_executable(path, source):
try:
import importlib.resources

if not hasattr(importlib.resources, 'files'):
if not hasattr(importlib.resources, "files"):
raise ImportError
wp = importlib.resources.files('setuptools').joinpath('cli-32.exe')
wp = importlib.resources.files("setuptools").joinpath("cli-32.exe")
w = wp.read_bytes()
except (ImportError, FileNotFoundError, SystemError):
pytest.skip(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def env(request):
def fin():
"""Cleanup test env"""
env_patch.stop()
shutil.rmtree(td, ignore_errors=os.name == 'nt')
shutil.rmtree(td, ignore_errors=os.name == "nt")

request.addfinalizer(fin)

Expand Down
Loading