Skip to content

Commit b26c866

Browse files
authored
Adopt sp-repo-review (#414)
* adopt sp-repo-review * Adopt sp-repo-review * fix typing * fix handling of report_async * cleanup * fix handling of super * fix header-license-fix
1 parent 6704acc commit b26c866

29 files changed

+461
-300
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ on:
1212
# The branches below must be a subset of the branches above
1313
branches: [main]
1414
schedule:
15-
- cron: '0 8 * * 3'
15+
- cron: "0 8 * * 3"
1616

1717
permissions:
18-
security-events:
19-
write
18+
security-events: write
2019

2120
jobs:
2221
analyze:
@@ -28,45 +27,45 @@ jobs:
2827
matrix:
2928
# Override automatic language detection by changing the below list
3029
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
31-
language: ['python']
30+
language: ["python"]
3231
# Learn more...
3332
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
3433

3534
steps:
36-
- name: Checkout repository
37-
uses: actions/checkout@v4
38-
with:
39-
# We must fetch at least the immediate parents so that if this is
40-
# a pull request then we can checkout the head.
41-
fetch-depth: 2
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
with:
38+
# We must fetch at least the immediate parents so that if this is
39+
# a pull request then we can checkout the head.
40+
fetch-depth: 2
4241

43-
# Initializes the CodeQL tools for scanning.
44-
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
46-
with:
47-
languages: ${{ matrix.language }}
48-
config-file: ./.github/codeql/codeql-config.yml
42+
# Initializes the CodeQL tools for scanning.
43+
- name: Initialize CodeQL
44+
uses: github/codeql-action/init@v2
45+
with:
46+
languages: ${{ matrix.language }}
47+
config-file: ./.github/codeql/codeql-config.yml
4948

50-
# If you wish to specify custom queries, you can do so here or in a config file.
51-
# By default, queries listed here will override any specified in a config file.
52-
# Prefix the list here with "+" to use these queries and those in the config file.
53-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5453

55-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
56-
# If this step fails, then you should remove it and run the build manually (see below)
57-
- name: Autobuild
58-
uses: github/codeql-action/autobuild@v2
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v2
5958

60-
# ℹ️ Command-line programs to run using the OS shell.
61-
# 📚 https://git.io/JvXDl
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
6261

63-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
64-
# and modify them (or add more) to build your code if your project
65-
# uses a compiled language
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
6665

67-
#- run: |
68-
# make bootstrap
69-
# make release
66+
#- run: |
67+
# make bootstrap
68+
# make release
7069

71-
- name: Perform CodeQL Analysis
72-
uses: github/codeql-action/analyze@v2
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v2

.github/workflows/fix-license-header.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: git config --global hub.protocol https
2222

2323
- name: Checkout the branch from the PR that triggered the job
24-
run: hub pr checkout ${{ github.event.pull_request.number }}
24+
run: gh pr checkout ${{ github.event.pull_request.number }}
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ jobs:
5858
steps:
5959
- uses: actions/checkout@v4
6060
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
61-
- name: Run Linters
62-
run: |
61+
- name: Run Linters
62+
run: |
6363
hatch run typing:test
6464
hatch run lint:style
6565
pipx run interrogate -v .

.pre-commit-config.yaml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ci:
22
autoupdate_schedule: monthly
3+
autoupdate_commit_msg: "chore: update pre-commit hooks"
34

45
repos:
56
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -15,6 +16,7 @@ repos:
1516
- id: check-json
1617
- id: check-toml
1718
- id: check-yaml
19+
- id: debug-statements
1820
- id: end-of-file-fixer
1921
- id: trailing-whitespace
2022

@@ -30,13 +32,44 @@ repos:
3032
additional_dependencies:
3133
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
3234

33-
- repo: https://github.com/psf/black
35+
- repo: https://github.com/pre-commit/mirrors-prettier
36+
rev: "v3.0.3"
37+
hooks:
38+
- id: prettier
39+
types_or: [yaml, json]
40+
41+
- repo: https://github.com/adamchainz/blacken-docs
42+
rev: "1.16.0"
43+
hooks:
44+
- id: blacken-docs
45+
additional_dependencies: [black==23.7.0]
46+
47+
- repo: https://github.com/psf/black-pre-commit-mirror
3448
rev: 23.9.1
3549
hooks:
3650
- id: black
3751

52+
- repo: https://github.com/codespell-project/codespell
53+
rev: "v2.2.6"
54+
hooks:
55+
- id: codespell
56+
args: ["-L", "sur,nd"]
57+
58+
- repo: https://github.com/pre-commit/pygrep-hooks
59+
rev: "v1.10.0"
60+
hooks:
61+
- id: rst-backticks
62+
- id: rst-directive-colons
63+
- id: rst-inline-touching-normal
64+
3865
- repo: https://github.com/astral-sh/ruff-pre-commit
39-
rev: v0.0.292
66+
rev: v0.1.1
4067
hooks:
4168
- id: ruff
42-
args: ["--fix"]
69+
args: ["--fix", "--show-fixes"]
70+
71+
- repo: https://github.com/scientific-python/cookie
72+
rev: "2023.09.21"
73+
hooks:
74+
- id: sp-repo-review
75+
additional_dependencies: ["repo-review[cli]"]

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.. jupyterlab_server documentation master file, created by
55
sphinx-quickstart on Tue Mar 30 03:25:58 2021.
66
You can adapt this file completely to your liking, but it should at least
7-
contain the root `toctree` directive.
7+
contain the root ``toctree`` directive.
88
99
Welcome to JupyterLab Server's documentation!
1010
=============================================

jupyterlab_server/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
from typing import Any
34

45
from ._version import __version__
56
from .app import LabServerApp
@@ -26,5 +27,5 @@
2627
]
2728

2829

29-
def _jupyter_server_extension_points():
30+
def _jupyter_server_extension_points() -> Any:
3031
return [{"module": "jupyterlab_server", "app": LabServerApp}]

jupyterlab_server/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
from jupyterlab_server.app import main
88

9-
sys.exit(main())
9+
sys.exit(main()) # type:ignore[no-untyped-call]

jupyterlab_server/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Build up version_info tuple for backwards compatibility
1313
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
1414
match = re.match(pattern, __version__)
15-
assert match is not None # noqa
15+
assert match is not None
1616
parts: list = [int(match[part]) for part in ["major", "minor", "patch"]]
1717
if match["rest"]:
1818
parts.append(match["rest"])

jupyterlab_server/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from glob import glob
77
from os.path import relpath
8+
from typing import Any
89

910
from jupyter_server.extension.application import ExtensionApp, ExtensionAppJinjaMixin
1011
from jupyter_server.utils import url_path_join as ujoin
@@ -23,7 +24,7 @@ class LabServerApp(ExtensionAppJinjaMixin, LabConfig, ExtensionApp):
2324
file_url_prefix = "/lab/tree" # type:ignore[assignment]
2425

2526
@property
26-
def app_namespace(self):
27+
def app_namespace(self) -> str: # type:ignore[override]
2728
return self.name
2829

2930
default_url = Unicode("/lab", help="The default URL to redirect to from `/`")
@@ -82,10 +83,10 @@ def app_namespace(self):
8283
# Method copied from
8384
# https://github.com/jupyterhub/jupyterhub/blob/d1a85e53dccfc7b1dd81b0c1985d158cc6b61820/jupyterhub/auth.py#L143-L161
8485
@observe(*list(_deprecated_aliases))
85-
def _deprecated_trait(self, change):
86+
def _deprecated_trait(self, change: Any) -> None:
8687
"""observer for deprecated traits"""
8788
old_attr = change.name
88-
new_attr, version = self._deprecated_aliases.get(old_attr) # type:ignore
89+
new_attr, version = self._deprecated_aliases.get(old_attr) # type:ignore[misc]
8990
new_value = getattr(self, new_attr)
9091
if new_value != change.new:
9192
# only warn if different
@@ -101,7 +102,7 @@ def _deprecated_trait(self, change):
101102
)
102103
setattr(self, new_attr, change.new)
103104

104-
def initialize_settings(self):
105+
def initialize_settings(self) -> None:
105106
"""Initialize the settings:
106107
107108
set the static files as immutable, since they should have all hashed name.
@@ -122,12 +123,12 @@ def initialize_settings(self):
122123

123124
self.settings.update({"static_immutable_cache": list(immutable_cache)})
124125

125-
def initialize_templates(self):
126+
def initialize_templates(self) -> None:
126127
"""Initialize templates."""
127128
self.static_paths = [self.static_dir]
128129
self.template_paths = [self.templates_dir]
129130

130-
def initialize_handlers(self):
131+
def initialize_handlers(self) -> None:
131132
"""Initialize handlers."""
132133
add_handlers(self.handlers, self)
133134

0 commit comments

Comments
 (0)