Skip to content

Commit

Permalink
Use pre-commit (#12279)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Mar 28, 2022
1 parent 2475a53 commit 6df5e0b
Show file tree
Hide file tree
Showing 164 changed files with 5,334 additions and 5,158 deletions.
10 changes: 5 additions & 5 deletions .bumpversion.cfg
@@ -1,14 +1,14 @@
[bumpversion]
current_version = 4, 0, 0, 'alpha', 22
current_version = 4, 0, 0, "alpha", 22
commit = False
tag = False
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \'(?P<release>\S+)\'\,\ (?P<build>\d+)
serialize =
{major}, {minor}, {patch}, '{release}', {build}
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \"(?P<release>\S+)\"\,\ (?P<build>\d+)
serialize =
{major}, {minor}, {patch}, "{release}", {build}

[bumpversion:part:release]
optional_value = final
values =
values =
alpha
beta
candidate
Expand Down
2 changes: 1 addition & 1 deletion .github/jupyterlab-probot.yml
@@ -1,3 +1,3 @@
binderUrlSuffix: "?urlpath=lab-dev"
addBinderLink: true
triageLabel: "status:Needs Triage"
triageLabel: "status:Needs Triage"
3 changes: 0 additions & 3 deletions .github/workflows/galata.yml
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- master
pull_request:
branches: '*'

jobs:
test:
Expand Down Expand Up @@ -168,13 +167,11 @@ jobs:
path: |
core/galata/playwright-report
- name: Stop JupyterLab
if: always()
run: |
kill -s SIGTERM $(pgrep jupyter-lab)
- name: Print JupyterLab logs
if: always()
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/linuxtests.yml
Expand Up @@ -138,3 +138,14 @@ jobs:
run: |
cd sdist/test
pytest -vv || pytest -vv --lf
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install Jupyterlab
run: pip install -e .
- uses: pre-commit/action@v2.0.0
4 changes: 2 additions & 2 deletions .meeseeksdev.yml
@@ -1,6 +1,6 @@
special:
everyone:
can:
can:
- say
- tag
- untag
- untag
73 changes: 73 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,73 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: forbid-new-submodules
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: trailing-whitespace
exclude: .bumpversion.cfg

- repo: https://github.com/psf/black
rev: 22.1.0
hooks:
- id: black
args: ["--line-length", "100"]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
files: \.py$
args: [--profile=black]

# - repo: https://github.com/pycqa/flake8
# rev: 4.0.1
# hooks:
# - id: flake8
# additional_dependencies:
# [
# "flake8-bugbear==20.1.4",
# "flake8-logging-format==0.6.0",
# "flake8-implicit-str-concat==0.2.0",
# ]

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.10.2
hooks:
- id: check-jsonschema
name: 'Check GitHub Workflows'
files: ^\.github/workflows/
types: [yaml]
args: ['--schemafile', 'https://json.schemastore.org/github-workflow']

- repo: local
hooks:
- id: prettier
name: prettier
entry: 'npm run prettier:files'
language: node
types_or: [json, markdown, ts, tsx, javascript, jsx, css]
- id: eslint
name: eslint
entry: 'npm run eslint:files'
language: node
types_or: [ts, tsx, javascript, jsx]
- id: stylelint
name: stylelint
entry: 'npm run stylelint:files'
language: node
types: [css]
- id: integrity
name: integrity
entry: 'npm run integrity --force'
language: node
stages: [push]
2 changes: 1 addition & 1 deletion .prettierrc
Expand Up @@ -2,4 +2,4 @@
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -6,7 +6,7 @@ RUN micromamba install -qy -c conda-forge python nodejs yarn \
&& chown jovyan $HOME

# Install npm packages - faster build thanks to caching
## package_json.tar.gz contains all package.json files using
## package_json.tar.gz contains all package.json files using
## `tar cvf package_json.tar.gz package.json packages/*/package.package_json`
ADD ./package_json.tar.gz /tmp/jupyterlab-dev
COPY yarn.lock /tmp/jupyterlab-dev
Expand Down
87 changes: 44 additions & 43 deletions binder/jupyter_notebook_config.py
@@ -1,58 +1,59 @@
common = [
'--no-browser',
'--debug',
'--port={port}',
'--ServerApp.ip=127.0.0.1',
"--no-browser",
"--debug",
"--port={port}",
"--ServerApp.ip=127.0.0.1",
'--ServerApp.token=""',
# Disable dns rebinding protection here, since our 'Host' header
# is not going to be localhost when coming from hub.mybinder.org
'--ServerApp.allow_remote_access=True'
"--ServerApp.allow_remote_access=True",
]

lab_command = ' '.join([
'jupyter',
'lab',
'--dev-mode',
'--extensions-in-dev-mode',
'--collaborative',
'--ServerApp.base_url={base_url}lab-dev',
] + common + ['>jupyterlab-dev.log 2>&1'])


lab_splice_command = ' '.join([
'jupyter',
'lab',
'build',
'--splice-source',
'--minimize=False',
'--dev-build=True',
'--debug',
'>jupyterlab-spliced.log 2>&1',
'&&',
'jupyter',
'lab',
'--ServerApp.base_url={base_url}lab-spliced',
] + common + ['>jupyterlab-spliced.log 2>&1'])
lab_command = " ".join(
[
"jupyter",
"lab",
"--dev-mode",
"--extensions-in-dev-mode",
"--collaborative",
"--ServerApp.base_url={base_url}lab-dev",
]
+ common
+ [">jupyterlab-dev.log 2>&1"]
)


lab_splice_command = " ".join(
[
"jupyter",
"lab",
"build",
"--splice-source",
"--minimize=False",
"--dev-build=True",
"--debug",
">jupyterlab-spliced.log 2>&1",
"&&",
"jupyter",
"lab",
"--ServerApp.base_url={base_url}lab-spliced",
]
+ common
+ [">jupyterlab-spliced.log 2>&1"]
)


c.ServerProxy.servers = {
'lab-dev': {
'command': [
'/bin/bash', '-c', lab_command
],
'timeout': 60,
'absolute_url': True
"lab-dev": {"command": ["/bin/bash", "-c", lab_command], "timeout": 60, "absolute_url": True},
"lab-spliced": {
"command": ["/bin/bash", "-c", lab_splice_command],
"timeout": 300,
"absolute_url": True,
},
'lab-spliced': {
'command': [
'/bin/bash', '-c', lab_splice_command
],
'timeout': 300,
'absolute_url': True
}
}

c.NotebookApp.default_url = '/lab-dev'
c.NotebookApp.default_url = "/lab-dev"

import logging

c.NotebookApp.log_level = logging.DEBUG
4 changes: 2 additions & 2 deletions binder/start
Expand Up @@ -3,10 +3,10 @@ import sys
import shutil
import os

argv = sys.argv[1:] + ['--config', 'binder/jupyter_notebook_config.py']
argv = sys.argv[1:] + ["--config", "binder/jupyter_notebook_config.py"]
print(argv)

with open('startup_args.txt', 'w') as fid:
with open("startup_args.txt", "w") as fid:
fid.write(str(argv))

os.execv(shutil.which(argv[0]), argv)
Empty file modified buildutils/src/patch-release.ts 100755 → 100644
Empty file.
Empty file modified buildutils/src/remove-package.ts 100755 → 100644
Empty file.
Empty file modified buildutils/src/update-dist-tag.ts 100755 → 100644
Empty file.
34 changes: 14 additions & 20 deletions clean.py
Expand Up @@ -5,38 +5,32 @@


# Workaround for https://github.com/git-for-windows/git/issues/607
if os.name == 'nt':
if os.name == "nt":
for (root, dnames, files) in os.walk(here):
if 'node_modules' in dnames:
subprocess.check_call(['rmdir', '/s', '/q', 'node_modules'],
cwd=root, shell=True)
dnames.remove('node_modules')
if "node_modules" in dnames:
subprocess.check_call(["rmdir", "/s", "/q", "node_modules"], cwd=root, shell=True)
dnames.remove("node_modules")


subprocess.check_call('python -m pip uninstall -y jupyterlab'.split(), cwd=here)
subprocess.check_call("python -m pip uninstall -y jupyterlab".split(), cwd=here)


def resolvePattern(pat):
"""handle a leading `#` or `@` in a pattern
"""
"""handle a leading `#` or `@` in a pattern"""
pat = pat.strip()

if not pat or pat.startswith('#'):
if not pat or pat.startswith("#"):
return []
elif pat.startswith('@'):
elif pat.startswith("@"):
raw = pat[1:]
return [
raw,
f'!packages/**/{raw}',
f'!**/node_modules/**/{raw}'
]
return [raw, f"!packages/**/{raw}", f"!**/node_modules/**/{raw}"]
else:
return [pat]


# get the exclude patterns listed in .cleanignore
with open(os.path.join(here, '.cleanignore')) as f:
git_clean_exclude = [f'--exclude={pat}'
for line in f
for pat in resolvePattern(line)]
with open(os.path.join(here, ".cleanignore")) as f:
git_clean_exclude = [f"--exclude={pat}" for line in f for pat in resolvePattern(line)]

git_clean_command = ['git', 'clean', '-dfx'] + git_clean_exclude
git_clean_command = ["git", "clean", "-dfx"] + git_clean_exclude
subprocess.check_call(git_clean_command, cwd=here)
9 changes: 3 additions & 6 deletions conftest.py
Expand Up @@ -5,11 +5,10 @@

import pytest


pytest_plugins = [
"jupyter_server.pytest_plugin",
"jupyterlab_server.pytest_plugin",
"jupyterlab.pytest_plugin"
"jupyterlab.pytest_plugin",
]


Expand All @@ -20,10 +19,8 @@ def pytest_addoption(parser):
This is called by the pytest API
"""
group = parser.getgroup("general")
group.addoption('--quick', action='store_true',
help="Skip slow tests")
group.addoption('--slow', action='store_true',
help="Run only slow tests")
group.addoption("--quick", action="store_true", help="Skip slow tests")
group.addoption("--slow", action="store_true", help="Run only slow tests")


def pytest_configure(config):
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_templates/copyright.html
Expand Up @@ -28,4 +28,4 @@
{%- endif %}

</p>
</div>
</div>

0 comments on commit 6df5e0b

Please sign in to comment.