From 8e9390d9af903f34bb1c8414c7e9b49d2fdec32f Mon Sep 17 00:00:00 2001 From: "Lumberbot (aka Jack)" <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:20:02 +0100 Subject: [PATCH] Backport PR #7132: Adopt ruff format (#7184) Co-authored-by: Steven Silvester --- .pre-commit-config.yaml | 14 +++++--------- notebook/app.py | 4 ++-- pyproject.toml | 23 ++++++++--------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a874dd58e..da34c9e88a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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| @@ -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]'] diff --git a/notebook/app.py b/notebook/app.py index 084a0f8031..53cc86e65b 100644 --- a/notebook/app.py +++ b/notebook/app.py @@ -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" diff --git a/pyproject.toml b/pyproject.toml index 6ff1d8dac0..23f7df3922 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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}" ] @@ -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", ] @@ -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 @@ -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"