Skip to content

Commit

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

* address lint

* address typing

* address warning

* don't test windows on 3.12 yet

* update fail_under

* update fail_under
  • Loading branch information
blink1073 authored Sep 10, 2023
1 parent d2a420d commit 8dfc199
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 116 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.7", "3.10"]
python-version: ["3.8", "3.11"]
include:
- os: windows-latest
python-version: "3.9"
python-version: "3.10"
- os: ubuntu-latest
python-version: "pypy-3.7"
python-version: "pypy-3.9"
- os: ubuntu-latest
python-version: "3.12"
- os: macos-latest
python-version: "3.8"
python-version: "3.12"
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
Expand All @@ -41,6 +43,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/report-coverage@v1
with:
fail_under: 75

check_release:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -122,8 +126,8 @@ 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
pipx run interrogate -v .
Expand Down
38 changes: 34 additions & 4 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 Down Expand Up @@ -28,16 +29,45 @@ repos:
rev: 0.7.17
hooks:
- id: mdformat
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.2"
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/psf/black-pre-commit-mirror
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.5"
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.287
hooks:
- id: ruff
args: ["--fix"]
args: ["--fix", "--show-fixes"]

- repo: https://github.com/scientific-python/cookie
rev: "2023.08.23"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ python:
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.11"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ No merged PRs

- Run only the basic test on Appveyor [#64](https://github.com/jupyter/terminado/pull/64) ([@blink1073](https://github.com/blink1073))
- Fix for https://github.com/jupyter/terminado/issues/62 [#63](https://github.com/jupyter/terminado/pull/63) ([@cpranav](https://github.com/cpranav))
- Add python_requires to help pip, and version classifers [#57](https://github.com/jupyter/terminado/pull/57) ([@hugovk](https://github.com/hugovk))
- Add python_requires to help pip, and version classifiers [#57](https://github.com/jupyter/terminado/pull/57) ([@hugovk](https://github.com/hugovk))
- Set websocket.terminal to None when the child exits [#55](https://github.com/jupyter/terminado/pull/55) ([@takluyver](https://github.com/takluyver))

## 0.8.1
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ you can add ``--user`` to the install commands.

Code Styling
-----------------------------
`terminado` has adopted automatic code formatting so you shouldn't
``terminado`` has adopted automatic code formatting so you shouldn't
need to worry too much about your code style.
As long as your code is valid,
the pre-commit hook should take care of how it should look.
`pre-commit` and its associated hooks will automatically be installed when
``pre-commit`` and its associated hooks will automatically be installed when
you run ``pip install -e ".[test]"``

To install ``pre-commit`` manually, run the following::
Expand Down
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,45 @@ Usage example:
import os.path
import tornado.web
import tornado.ioloop

# This demo requires tornado_xstatic and XStatic-term.js
import tornado_xstatic

import terminado

STATIC_DIR = os.path.join(os.path.dirname(terminado.__file__), "_static")


class TerminalPageHandler(tornado.web.RequestHandler):
def get(self):
return self.render("termpage.html", static=self.static_url,
xstatic=self.application.settings['xstatic_url'],
ws_url_path="/websocket")
return self.render(
"termpage.html",
static=self.static_url,
xstatic=self.application.settings["xstatic_url"],
ws_url_path="/websocket",
)


if __name__ == '__main__':
term_manager = terminado.SingleTermManager(shell_command=['bash'])
if __name__ == "__main__":
term_manager = terminado.SingleTermManager(shell_command=["bash"])
handlers = [
(r"/websocket", terminado.TermSocket,
{'term_manager': term_manager}),
(r"/", TerminalPageHandler),
(r"/xstatic/(.*)", tornado_xstatic.XStaticFileHandler,
{'allowed_modules': ['termjs']})
]
app = tornado.web.Application(handlers, static_path=STATIC_DIR,
xstatic_url = tornado_xstatic.url_maker('/xstatic/'))
(r"/websocket", terminado.TermSocket, {"term_manager": term_manager}),
(r"/", TerminalPageHandler),
(
r"/xstatic/(.*)",
tornado_xstatic.XStaticFileHandler,
{"allowed_modules": ["termjs"]},
),
]
app = tornado.web.Application(
handlers,
static_path=STATIC_DIR,
xstatic_url=tornado_xstatic.url_maker("/xstatic/"),
)
# Serve at http://localhost:8765/ N.B. Leaving out 'localhost' here will
# work, but it will listen on the public network interface as well.
# Given what terminado does, that would be rather a security hole.
app.listen(8765, 'localhost')
app.listen(8765, "localhost")
try:
tornado.ioloop.IOLoop.instance().start()
finally:
Expand Down
3 changes: 2 additions & 1 deletion demos/templates/termpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
style="
visibility: hidden;
border: white solid 5px;
font-family: 'DejaVu Sans Mono', 'Liberation Mono', monospace;
font-family: "DejaVu Sans Mono", "Liberation Mono",
monospace;
font-size: 11px;
"
>0
Expand Down
48 changes: 28 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Homepage = "https://github.com/jupyter/terminado"
test = [ "pytest>=7.0", "pre-commit", "pytest-timeout",]
docs = [ "sphinx", "pydata-sphinx-theme", "myst_parser"]

typing = ["mypy>=0.990"]
typing = ["mypy>=1.5.1"]

[tool.hatch.version]
path = "terminado/_version.py"
Expand All @@ -49,7 +49,7 @@ nowarn = "test -W default {args}"
[tool.hatch.envs.typing]
features = ["typing", "test"]
[tool.hatch.envs.typing.scripts]
test = "mypy --install-types --non-interactive {args:terminado}"
test = "mypy --install-types --non-interactive {args}"

[tool.hatch.envs.lint]
dependencies = [
Expand All @@ -71,11 +71,21 @@ fmt = [
]

[tool.pytest.ini_options]
addopts = "-raXs --durations 10 --color=yes --doctest-modules"
minversion = "6.0"
xfail_strict = true
log_cli_level = "info"
addopts = [
"-raXs", "--durations=10", "--color=yes", "--doctest-modules",
"--showlocals", "--strict-markers", "--strict-config"
]
testpaths = [
"terminado/tests/"
"tests/"
]
timeout = 300
filterwarnings = [
"error",
"module:unclosed <socket.socket:ResourceWarning",
]
# Restore this setting to debug failures
# timeout_method = "thread"

Expand All @@ -98,26 +108,18 @@ relative_files = true
source = ["terminado"]

[tool.mypy]
check_untyped_defs = true
disallow_incomplete_defs = true
no_implicit_optional = true
pretty = true
show_error_context = true
files = "terminado"
python_version = "3.8"
strict = true
show_error_codes = true
strict_equality = true
strict_optional = true
warn_no_return = true
warn_return_any = true
warn_unused_configs = true
warn_unused_ignores = true
warn_redundant_casts = true

enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true

[tool.black]
line-length = 100
skip-string-normalization = true
target-version = ["py38"]
extend-exclude = "^/tests.*ipynb$"
extend-exclude = "^tests.*ipynb$"

[tool.ruff]
target-version = "py38"
Expand Down Expand Up @@ -157,7 +159,7 @@ unfixable = [
# B007 Loop control variable `i` not used within the loop body.
# N802 Function name `assertIn` should be lowercase
# S101 Use of `assert` detected
"terminado/tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "S101"]
"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "S101"]

[tool.interrogate]
ignore-init-module=true
Expand All @@ -167,4 +169,10 @@ ignore-property-decorators=true
ignore-nested-functions=true
ignore-nested-classes=true
fail-under=100
exclude = ["demos", "doc", "terminado/tests"]
exclude = ["demos", "doc", "tests"]

[tool.codespell]
ignore-words-list = "incase"

[tool.repo-review]
ignore = ["PY007", "PP308", "GH102", "PC140"]
Loading

0 comments on commit 8dfc199

Please sign in to comment.