Skip to content

Commit

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* lint

* cleanup matrix

* update lint job

* add check job

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
blink1073 and pre-commit-ci[bot] authored Nov 4, 2023
1 parent 234c93d commit 51271bd
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 100 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
schedule:
- cron: "0 8 * * *"

Expand All @@ -14,16 +15,16 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.7", "3.11"]
python-version: ["3.8", "3.12"]
include:
- os: windows-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "pypy-3.8"
python-version: "pypy-3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.8"
python-version: "3.11"
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -38,10 +39,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- 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
hatch run lint:build
pipx run 'validate-pyproject[all]' pyproject.toml
check_release:
Expand All @@ -66,3 +67,17 @@ jobs:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1

check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- check_links
- check_release
- test_lint
- build
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
79 changes: 79 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ci:
autoupdate_schedule: monthly
autoupdate_commit_msg: "chore: update pre-commit hooks"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace

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

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
hooks:
- id: prettier
types_or: [yaml, html, 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/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/pre-commit/mirrors-mypy
rev: "v1.6.1"
hooks:
- id: mypy
files: comm
stages: [manual]
additional_dependencies: ["traitlets>=5.13"]

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

- repo: https://github.com/scientific-python/cookie
rev: "2023.10.27"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import comm


class MyCustomComm(comm.base_comm.BaseComm):

def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys):
# TODO implement the logic for sending comm messages through the iopub channel
pass
Expand Down
18 changes: 14 additions & 4 deletions comm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
the Jupyter kernel protocol.
It also provides a base Comm implementation and a default CommManager for the IPython case.
"""
from __future__ import annotations

from .base_comm import BaseComm, CommManager
from typing import Any

from .base_comm import BaseComm, BuffersType, CommManager, MaybeDict

__version__ = "0.1.4"
__all__ = [
Expand All @@ -21,19 +24,26 @@


class DummyComm(BaseComm):
def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys):
def publish_msg(
self,
msg_type: str,
data: MaybeDict = None,
metadata: MaybeDict = None,
buffers: BuffersType = None,
**keys: Any,
) -> None:
pass


def _create_comm(*args, **kwargs):
def _create_comm(*args: Any, **kwargs: Any) -> BaseComm:
"""Create a Comm.
This method is intended to be replaced, so that it returns your Comm instance.
"""
return DummyComm(*args, **kwargs)


def _get_comm_manager():
def _get_comm_manager() -> CommManager:
"""Get the current Comm manager, creates one if there is none.
This method is intended to be replaced if needed (if you want to manage multiple CommManagers).
Expand Down
Loading

0 comments on commit 51271bd

Please sign in to comment.