Skip to content

Commit

Permalink
Adopt sp-repo-review (#414)
Browse files Browse the repository at this point in the history
* adopt sp-repo-review

* Adopt sp-repo-review

* fix typing

* fix handling of report_async

* cleanup

* fix handling of super

* fix header-license-fix
  • Loading branch information
blink1073 authored Oct 24, 2023
1 parent 6704acc commit b26c866
Show file tree
Hide file tree
Showing 29 changed files with 461 additions and 300 deletions.
67 changes: 33 additions & 34 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ on:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '0 8 * * 3'
- cron: "0 8 * * 3"

permissions:
security-events:
write
security-events: write

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

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

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

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

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

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

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/fix-license-header.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: git config --global hub.protocol https

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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Run Linters
run: |
- name: Run Linters
run: |
hatch run typing:test
hatch run lint:style
pipx run interrogate -v .
Expand Down
39 changes: 36 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ci:
autoupdate_schedule: monthly
autoupdate_commit_msg: "chore: update pre-commit hooks"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -15,6 +16,7 @@ repos:
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace

Expand All @@ -30,13 +32,44 @@ repos:
additional_dependencies:
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]

- repo: https://github.com/psf/black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
hooks:
- id: prettier
types_or: [yaml, json]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- 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"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

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

- repo: https://github.com/scientific-python/cookie
rev: "2023.09.21"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.. jupyterlab_server documentation master file, created by
sphinx-quickstart on Tue Mar 30 03:25:58 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
contain the root ``toctree`` directive.
Welcome to JupyterLab Server's documentation!
=============================================
Expand Down
3 changes: 2 additions & 1 deletion jupyterlab_server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from typing import Any

from ._version import __version__
from .app import LabServerApp
Expand All @@ -26,5 +27,5 @@
]


def _jupyter_server_extension_points():
def _jupyter_server_extension_points() -> Any:
return [{"module": "jupyterlab_server", "app": LabServerApp}]
2 changes: 1 addition & 1 deletion jupyterlab_server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

from jupyterlab_server.app import main

sys.exit(main())
sys.exit(main()) # type:ignore[no-untyped-call]
2 changes: 1 addition & 1 deletion jupyterlab_server/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Build up version_info tuple for backwards compatibility
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
match = re.match(pattern, __version__)
assert match is not None # noqa
assert match is not None
parts: list = [int(match[part]) for part in ["major", "minor", "patch"]]
if match["rest"]:
parts.append(match["rest"])
Expand Down
13 changes: 7 additions & 6 deletions jupyterlab_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from glob import glob
from os.path import relpath
from typing import Any

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

@property
def app_namespace(self):
def app_namespace(self) -> str: # type:ignore[override]
return self.name

default_url = Unicode("/lab", help="The default URL to redirect to from `/`")
Expand Down Expand Up @@ -82,10 +83,10 @@ def app_namespace(self):
# Method copied from
# https://github.com/jupyterhub/jupyterhub/blob/d1a85e53dccfc7b1dd81b0c1985d158cc6b61820/jupyterhub/auth.py#L143-L161
@observe(*list(_deprecated_aliases))
def _deprecated_trait(self, change):
def _deprecated_trait(self, change: Any) -> None:
"""observer for deprecated traits"""
old_attr = change.name
new_attr, version = self._deprecated_aliases.get(old_attr) # type:ignore
new_attr, version = self._deprecated_aliases.get(old_attr) # type:ignore[misc]
new_value = getattr(self, new_attr)
if new_value != change.new:
# only warn if different
Expand All @@ -101,7 +102,7 @@ def _deprecated_trait(self, change):
)
setattr(self, new_attr, change.new)

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

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

def initialize_templates(self):
def initialize_templates(self) -> None:
"""Initialize templates."""
self.static_paths = [self.static_dir]
self.template_paths = [self.templates_dir]

def initialize_handlers(self):
def initialize_handlers(self) -> None:
"""Initialize handlers."""
add_handlers(self.handlers, self)

Expand Down
Loading

0 comments on commit b26c866

Please sign in to comment.