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

Backport PR #7132 on branch 7.0.x (Adopt ruff format) #7184

Merged
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
14 changes: 5 additions & 9 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 @@ -31,16 +31,11 @@ repos:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

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

- repo: https://github.com/codespell-project/codespell
rev: 'v2.2.6'
hooks:
- id: codespell
args: ['-L', 'sur,nd']
args: ['-L', 'hart,noteable']
exclude: |
(?x)^(
yarn.lock|
Expand All @@ -56,13 +51,14 @@ repos:
- id: rst-inline-touching-normal

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

- repo: https://github.com/scientific-python/cookie
rev: '2023.09.21'
rev: '2023.10.27'
hooks:
- id: sp-repo-review
additional_dependencies: ['repo-review[cli]']
Expand Down
4 changes: 2 additions & 2 deletions notebook/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ class CustomCssHandler(NotebookBaseHandler):
def get(self) -> t.Any:
"""Get the custom css file."""

self.set_header("Content-Type", 'text/css')
self.set_header("Content-Type", "text/css")
page_config = self.get_page_config()
custom_css_file = f"{page_config['jupyterConfigDir']}/custom/custom.css"

if not os.path.isfile(custom_css_file):
static_path_root = re.match('^(.*?)static', page_config['staticDir'])
static_path_root = re.match("^(.*?)static", page_config["staticDir"])
if static_path_root is not None:
custom_dir = static_path_root.groups()[0]
custom_css_file = f"{custom_dir}custom/custom.css"
Expand Down
23 changes: 8 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,20 @@ test = "mypy --install-types --non-interactive {args}"

[tool.hatch.envs.lint]
dependencies = [
"black[jupyter]==22.10.0",
"mdformat>0.7",
"mdformat-gfm>=0.3.5",
"ruff==0.0.276"
"ruff==0.1.3"
]
detached = true
[tool.hatch.envs.lint.scripts]
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
"ruff format {args:.}",
"mdformat --check {args:CHANGELOG.md}"
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"ruff format {args:.}",
"mdformat {args:CHANGELOG.md}"
]

Expand Down Expand Up @@ -246,16 +245,13 @@ show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true

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

[tool.ruff]
target-version = "py37"
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 @@ -270,7 +266,7 @@ ignore = [
"RUF012",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# S101 Use of `assert` detected
# F841 Local variable `foo` is assigned to but never used
# PLR2004 Magic value used in comparison
Expand All @@ -290,6 +286,3 @@ exclude = ["tests", "ui-tests", "docs", "node_modules", "setup.py"]

[tool.repo-review]
ignore = ["PY007", "PP308", "GH102", "PC140", "PC180"]

[tool.codespell]
ignore-words-list = "hart,noteable"
Loading