Skip to content

Commit e4f4472

Browse files
committed
add auto-formatting
1 parent 0ba4fc9 commit e4f4472

File tree

7 files changed

+95
-52
lines changed

7 files changed

+95
-52
lines changed

.pre-commit-config.yaml

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,69 @@
1+
ci:
2+
skip: [check-jsonschema]
3+
14
repos:
2-
- repo: https://github.com/asottile/reorder_python_imports
3-
rev: v3.0.1
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.1.0
47
hooks:
5-
- id: reorder-python-imports
8+
- id: end-of-file-fixer
9+
- id: check-case-conflict
10+
- id: check-executables-have-shebangs
11+
- id: requirements-txt-fixer
12+
- id: check-added-large-files
13+
- id: check-case-conflict
14+
- id: check-toml
15+
- id: check-yaml
16+
- id: debug-statements
17+
- id: forbid-new-submodules
18+
- id: check-builtin-literals
19+
- id: trailing-whitespace
20+
621
- repo: https://github.com/psf/black
722
rev: 22.3.0
823
hooks:
924
- id: black
1025
args: ["--line-length", "100"]
11-
- repo: https://gitlab.com/pycqa/flake8
12-
rev: "3.9.2"
26+
27+
- repo: https://github.com/PyCQA/isort
28+
rev: 5.10.1
1329
hooks:
14-
- id: flake8
15-
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v4.1.0
30+
- id: isort
31+
files: \.py$
32+
args: [--profile=black]
33+
34+
- repo: https://github.com/pre-commit/mirrors-prettier
35+
rev: v2.6.1
1736
hooks:
18-
- id: end-of-file-fixer
19-
- id: check-case-conflict
20-
- id: check-executables-have-shebangs
21-
- id: requirements-txt-fixer
37+
- id: prettier
38+
39+
- repo: https://github.com/asottile/pyupgrade
40+
rev: v2.31.1
41+
hooks:
42+
- id: pyupgrade
43+
args: [--py37-plus]
44+
45+
- repo: https://github.com/PyCQA/doc8
46+
rev: 0.11.0
47+
hooks:
48+
- id: doc8
49+
args: [--max-line-length=200]
50+
51+
# - repo: https://github.com/pycqa/flake8
52+
# rev: 4.0.1
53+
# hooks:
54+
# - id: flake8
55+
# additional_dependencies:
56+
# [
57+
# "flake8-bugbear==20.1.4",
58+
# "flake8-logging-format==0.6.0",
59+
# "flake8-implicit-str-concat==0.2.0",
60+
# ]
61+
62+
- repo: https://github.com/sirosen/check-jsonschema
63+
rev: 0.14.1
64+
hooks:
65+
- id: check-jsonschema
66+
name: "Check GitHub Workflows"
67+
files: ^\.github/workflows/
68+
types: [yaml]
69+
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

docs/source/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# Jupyter Server documentation build configuration file, created by
54
# sphinx-quickstart on Mon Apr 13 09:51:11 2015.
@@ -328,7 +327,7 @@
328327

329328
# -- Options for link checks ----------------------------------------------
330329

331-
linkcheck_ignore = ["http://127\.0\.0\.1/*"]
330+
linkcheck_ignore = [r"http://127\.0\.0\.1/*"]
332331

333332

334333
# -- Options for Texinfo output -------------------------------------------
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"ServerApp": {
3-
"jpserver_extensions": {
4-
"jupyter_server_terminals": true
5-
}
2+
"ServerApp": {
3+
"jpserver_extensions": {
4+
"jupyter_server_terminals": true
65
}
6+
}
77
}

jupyter_server_terminals/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
from traitlets import Type
66

7-
from . import api_handlers
8-
from . import handlers
7+
from . import api_handlers, handlers
98
from .terminalmanager import TerminalManager
109

1110
try:
1211
from jupyter_server.extension.application import ExtensionApp
13-
from jupyter_server.utils import run_sync_in_loop
1412
from jupyter_server.transutils import trans
13+
from jupyter_server.utils import run_sync_in_loop
1514

1615
# Tolerate missing terminado package.
1716
try:

jupyter_server_terminals/handlers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# encoding: utf-8
21
"""Tornado handlers for the terminal emulator."""
32
# Copyright (c) Jupyter Development Team.
43
# Distributed under the terms of the Modified BSD License.
@@ -27,14 +26,14 @@ def get(self, *args, **kwargs):
2726
raise web.HTTPError(403)
2827
if not args[0] in self.term_manager.terminals:
2928
raise web.HTTPError(404)
30-
return super(TermSocket, self).get(*args, **kwargs)
29+
return super().get(*args, **kwargs)
3130

3231
def on_message(self, message):
33-
super(TermSocket, self).on_message(message)
32+
super().on_message(message)
3433
self._update_activity()
3534

3635
def write_message(self, message, binary=False):
37-
super(TermSocket, self).write_message(message, binary=binary)
36+
super().write_message(message, binary=binary)
3837
self._update_activity()
3938

4039
def _update_activity(self):

jupyter_server_terminals/rest-api.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ info:
77
url: https://jupyter.org
88
version: "1"
99
servers:
10-
- url: /
10+
- url: /
1111
paths:
1212
/api/terminals:
1313
get:
1414
tags:
15-
- terminals
15+
- terminals
1616
summary: Get available terminals
1717
responses:
1818
200:
@@ -22,7 +22,7 @@ paths:
2222
schema:
2323
type: array
2424
items:
25-
$ref: '#/components/schemas/Terminal'
25+
$ref: "#/components/schemas/Terminal"
2626
403:
2727
description: Forbidden to access
2828
content: {}
@@ -31,15 +31,15 @@ paths:
3131
content: {}
3232
post:
3333
tags:
34-
- terminals
34+
- terminals
3535
summary: Create a new terminal
3636
responses:
3737
200:
3838
description: Succesfully created a new terminal
3939
content:
4040
application/json:
4141
schema:
42-
$ref: '#/components/schemas/Terminal'
42+
$ref: "#/components/schemas/Terminal"
4343
403:
4444
description: Forbidden to access
4545
content: {}
@@ -49,22 +49,22 @@ paths:
4949
/api/terminals/{terminal_id}:
5050
get:
5151
tags:
52-
- terminals
52+
- terminals
5353
summary: Get a terminal session corresponding to an id.
5454
parameters:
55-
- name: terminal_id
56-
in: path
57-
description: ID of terminal session
58-
required: true
59-
schema:
60-
type: string
55+
- name: terminal_id
56+
in: path
57+
description: ID of terminal session
58+
required: true
59+
schema:
60+
type: string
6161
responses:
6262
200:
6363
description: Terminal session with given id
6464
content:
6565
application/json:
6666
schema:
67-
$ref: '#/components/schemas/Terminal'
67+
$ref: "#/components/schemas/Terminal"
6868
403:
6969
description: Forbidden to access
7070
content: {}
@@ -73,15 +73,15 @@ paths:
7373
content: {}
7474
delete:
7575
tags:
76-
- terminals
76+
- terminals
7777
summary: Delete a terminal session corresponding to an id.
7878
parameters:
79-
- name: terminal_id
80-
in: path
81-
description: ID of terminal session
82-
required: true
83-
schema:
84-
type: string
79+
- name: terminal_id
80+
in: path
81+
description: ID of terminal session
82+
required: true
83+
schema:
84+
type: string
8585
responses:
8686
204:
8787
description: Succesfully deleted terminal session
@@ -96,7 +96,7 @@ components:
9696
schemas:
9797
Terminal:
9898
required:
99-
- name
99+
- name
100100
type: object
101101
properties:
102102
name:

jupyter_server_terminals/terminalmanager.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
import terminado
1010
from tornado import web
11-
from tornado.ioloop import IOLoop
12-
from tornado.ioloop import PeriodicCallback
11+
from tornado.ioloop import IOLoop, PeriodicCallback
1312
from traitlets import Integer
1413
from traitlets.config import LoggingConfigurable
1514

1615
try:
17-
from jupyter_server._tz import isoformat
18-
from jupyter_server._tz import utcnow
16+
from jupyter_server._tz import isoformat, utcnow
1917
from jupyter_server.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL
2018
except ModuleNotFoundError:
2119
raise ModuleNotFoundError("Jupyter Server must be installed to use this extension.")
@@ -46,7 +44,7 @@ class TerminalManager(LoggingConfigurable, terminado.NamedTermManager):
4644
# Methods for managing terminals
4745
# -------------------------------------------------------------------------
4846
def __init__(self, *args, **kwargs):
49-
super(TerminalManager, self).__init__(*args, **kwargs)
47+
super().__init__(*args, **kwargs)
5048

5149
def create(self, **kwargs):
5250
"""Create a new terminal."""
@@ -78,7 +76,7 @@ def list(self):
7876
async def terminate(self, name, force=False):
7977
"""Terminate terminal 'name'."""
8078
self._check_terminal(name)
81-
await super(TerminalManager, self).terminate(name, force=force)
79+
await super().terminate(name, force=force)
8280

8381
# Decrease the metric below by one
8482
# because a terminal has been shutdown

0 commit comments

Comments
 (0)