Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-prefdir
Browse files Browse the repository at this point in the history
  • Loading branch information
vidartf committed Dec 7, 2022
2 parents cb7f370 + ed99ddc commit e763216
Show file tree
Hide file tree
Showing 65 changed files with 762 additions and 541 deletions.
8 changes: 6 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
version: 2
updates:
# Set update schedule for GitHub Actions
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "weekly"
# Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
21 changes: 14 additions & 7 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,28 @@ jobs:
pip install codecov coverage[toml]
codecov
pre_commit:
name: pre-commit
test_docs:
name: Test Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1
- run: hatch run docs:build

test_docs:
name: Test Docs
test_lint:
name: Test Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- run: hatch run docs:build
- name: Run Linters
run: |
hatch run typing:test
hatch run lint:style
pipx run 'validate-pyproject[all]' pyproject.toml
pipx run doc8 --max-line-length=200 --ignore-path=docs/source/other/full-config.rst
npm install -g eslint
eslint .
test_examples:
name: Test Examples
Expand Down Expand Up @@ -157,8 +164,8 @@ jobs:
if: always()
needs:
- build
- pre_commit
- test_docs
- test_lint
- test_minimum_versions
- test_prereleases
- check_links
Expand Down
65 changes: 12 additions & 53 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
node: system
ci:
autoupdate_schedule: monthly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -18,64 +18,23 @@ repos:
- id: check-builtin-literals
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
files: \.py$

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
additional_dependencies: [types-requests]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.10.1
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.19.2
hooks:
- id: validate-pyproject
stages: [manual]
- id: check-github-workflows

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
hooks:
- id: doc8
args: [--max-line-length=200]
exclude: docs/source/other/full-config.rst
stages: [manual]

- repo: https://github.com/john-hen/Flake8-pyproject
rev: 1.2.1
hooks:
- id: Flake8-pyproject
alias: flake8
additional_dependencies:
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"]
stages: [manual]

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.28.0
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: eslint
stages: [manual]
- id: black

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.19.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.165
hooks:
- id: check-github-workflows
- id: ruff
args: ["--fix"]
136 changes: 134 additions & 2 deletions CHANGELOG.md

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ from any directory in your system with::
jupyter server


Code Styling
-----------------------------
Code Styling and Quality Checks
-------------------------------
`jupyter_server` 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,
Expand Down Expand Up @@ -69,6 +69,11 @@ yourself after that.
Some of the hooks only run on CI by default, but you can invoke them by
running with the ``--hook-stage manual`` argument.

There are three hatch scripts that can be run locally as well:
``hatch run lint:style`` will check styling. ``hatch run lint:fmt``
will attempt to auto-format files. ``hatch run typing:test`` will
run the type checker.

Troubleshooting the Installation
--------------------------------

Expand Down
9 changes: 8 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ coverage:
threshold: 1
patch:
default:
target: 0%
target: 50%
notify:
wait_for_ci: true
range: 80..100
github_checks:
annotations: false
comment:
after_n_builds: 30
25 changes: 14 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import logging
import os
import os.path as osp
import shutil
Expand All @@ -27,26 +28,28 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.

# DEBUG for RTD
print("DEBUG:: sys.path")
print("================")
log = logging.getLogger(__name__)
info = log.info
info("DEBUG:: sys.path")
info("================")
for item in sys.path:
print(item)
info(item)

# add repo root to sys.path
# here = root/docs/source
here = os.path.abspath(os.path.dirname(__file__))
repo_root = os.path.dirname(os.path.dirname(here))
sys.path.insert(0, repo_root)

print("repo_root")
print("=====================")
print(repo_root)
info("repo_root")
info("=====================")
info(repo_root)

# DEBUG for post insert on RTD
print("DEBUG:: Post insert to sys.path")
print("===============================")
info("DEBUG:: Post insert to sys.path")
info("===============================")
for item in sys.path:
print(item)
info(item)

# Check if docs are being built by ReadTheDocs
# If so, generate a config.rst file and populate it with documentation about
Expand All @@ -57,7 +60,7 @@
# Readthedocs doesn't run our Makefile, so we do this to force it to generate
# the config docs.
with open("../autogen_config.py") as f:
exec(compile(f.read(), "../autogen_config.py", "exec"), {})
exec(compile(f.read(), "../autogen_config.py", "exec"), {}) # noqa

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -112,7 +115,7 @@
__version__ = version("jupyter_server")
# The short X.Y version.
version_parsed = parse_version(__version__)
version = f"{version_parsed.major}.{version_parsed.minor}" # type:ignore[assignment]
version = f"{version_parsed.major}.{version_parsed.minor}" # type:ignore

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 0 additions & 5 deletions docs/source/operators/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ you can set a password for your server.
:command:`jupyter server password` will prompt you for a password,
and store the hashed password in your :file:`jupyter_server_config.json`.

.. versionadded:: 5.0

:command:`jupyter server password` command is added.


It is possible disable authentication altogether by setting the token and password to empty strings,
but this is **NOT RECOMMENDED**, unless authentication or access restrictions are handled at a different layer in your web application:

Expand Down
26 changes: 13 additions & 13 deletions examples/simple/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from jupyter_packaging import create_cmdclass
from jupyter_packaging import create_cmdclass # type:ignore
from setuptools import setup

VERSION = "0.0.1"
Expand Down Expand Up @@ -32,29 +32,29 @@ def add_data_files(path):

cmdclass = create_cmdclass(data_files_spec=get_data_files())

setup_args = dict(
name="jupyter_server_example",
version=VERSION,
description="Jupyter Server Example",
long_description=open("README.md").read(),
python_requires=">=3.8",
install_requires=[
setup_args = {
"name": "jupyter_server_example",
"version": VERSION,
"description": "Jupyter Server Example",
"long_description": open("README.md").read(),
"python_requires": ">=3.8",
"install_requires": [
"jupyter_server",
"jinja2",
],
extras_require={
"extras_require": {
"test": ["pytest", "pytest-asyncio"],
},
include_package_data=True,
cmdclass=cmdclass,
entry_points={
"include_package_data": True,
"cmdclass": cmdclass,
"entry_points": {
"console_scripts": [
"jupyter-simple-ext1 = simple_ext1.application:main",
"jupyter-simple-ext11 = simple_ext11.application:main",
"jupyter-simple-ext2 = simple_ext2.application:main",
]
},
)
}


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions examples/simple/simple_ext1/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class SimpleApp1(ExtensionAppJinjaMixin, ExtensionApp):
# Local path to templates directory.
template_paths = [DEFAULT_TEMPLATE_FILES_PATH]

configA = Unicode("", config=True, help="Config A example.")
configA = Unicode("", config=True, help="Config A example.") # noqa

configB = Unicode("", config=True, help="Config B example.")
configB = Unicode("", config=True, help="Config B example.") # noqa

configC = Unicode("", config=True, help="Config C example.")
configC = Unicode("", config=True, help="Config C example.") # noqa

def initialize_handlers(self):
self.handlers.extend(
Expand Down
5 changes: 1 addition & 4 deletions examples/simple/simple_ext1/handlers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from jupyter_server.auth import authorized
from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.extension.handler import (
ExtensionHandlerJinjaMixin,
ExtensionHandlerMixin,
)
from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin
from jupyter_server.utils import url_escape


Expand Down
2 changes: 1 addition & 1 deletion examples/simple/simple_ext11/application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from simple_ext1.application import SimpleApp1
from simple_ext1.application import SimpleApp1 # type:ignore
from traitlets import Bool, Unicode, observe

from jupyter_server.serverapp import aliases, flags
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/simple_ext2/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SimpleApp2(ExtensionAppJinjaMixin, ExtensionApp):
# Local path to templates directory.
template_paths = [DEFAULT_TEMPLATE_FILES_PATH]

configD = Unicode("", config=True, help="Config D example.")
configD = Unicode("", config=True, help="Config D example.") # noqa

def initialize_handlers(self):
self.handlers.extend(
Expand Down
6 changes: 1 addition & 5 deletions examples/simple/simple_ext2/handlers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.extension.handler import (
ExtensionHandlerJinjaMixin,
ExtensionHandlerMixin,
)
from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin
from jupyter_server.utils import url_escape


Expand All @@ -27,7 +24,6 @@ def get(self):

class TemplateHandler(BaseTemplateHandler):
def get(self, path):
print(self.get_template("simple_ext2.html"))
self.write(self.render_template("simple_ext2.html", path=path))


Expand Down
22 changes: 11 additions & 11 deletions jupyter_server/_sysinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ def pkg_info(pkg_path):
with named parameters of interest
"""
src, hsh = pkg_commit_hash(pkg_path)
return dict(
jupyter_server_version=jupyter_server.__version__,
jupyter_server_path=pkg_path,
commit_source=src,
commit_hash=hsh,
sys_version=sys.version,
sys_executable=sys.executable,
sys_platform=sys.platform,
platform=platform.platform(),
os_name=os.name,
)
return {
"jupyter_server_version": jupyter_server.__version__,
"jupyter_server_path": pkg_path,
"commit_source": src,
"commit_hash": hsh,
"sys_version": sys.version,
"sys_executable": sys.executable,
"sys_platform": sys.platform,
"platform": platform.platform(),
"os_name": os.name,
}


def get_sys_info():
Expand Down
Loading

0 comments on commit e763216

Please sign in to comment.