Skip to content

Adopt ruff and typing #6658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Is this a bug in Notebook? Open an issue.
about: If you're not sure, feel free to post your question on Jupyter's Discourse
about:
If you're not sure, feel free to post your question on Jupyter's Discourse
channel.

labels: bug
Expand Down
6 changes: 4 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: 2
updates:
# Set update schedule for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,30 @@ jobs:
with:
ignore_links: "https://playwright.dev/docs/test-cli/ https://blog.jupyter.org/the-big-split-9d7b88a031a7 https://blog.jupyter.org/jupyter-ascending-1bf5b362d97e"

pre_commit:
test_lint:
name: Test Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- run: pip install -e .
- uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1

- 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 docs/source *.md
npm install -g yarn
yarn
yarn eslint:check
yarn prettier:check
yarn integrity

tests_check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- test
- install
- pre_commit
- test_lint
- test_docs
- test_minimum_versions
- test_prereleases
Expand Down
55 changes: 13 additions & 42 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ci:
autoupdate_schedule: monthly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: forbid-new-submodules
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-executables-have-shebangs
Expand All @@ -12,56 +14,25 @@ repos:
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: forbid-new-submodules
- id: check-builtin-literals
- id: trailing-whitespace
exclude: .bumpversion.cfg

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

- repo: https://github.com/psf/black
rev: 22.10.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/doc8
rev: v1.0.0
hooks:
- id: doc8
args: [--max-line-length=200]
stages: [manual]

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

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

- repo: https://github.com/john-hen/Flake8-pyproject
rev: 1.2.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.165
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/python-jsonschema/check-jsonschema
rev: 0.19.2
hooks:
- id: check-github-workflows
- id: ruff
args: ["--fix"]

- repo: local
hooks:
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
node_modules
.mypy_cache
.ruff_cache
**/node_modules
**/lib
**/package.json
**/static
**/labextension
build
CHANGELOG.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The Jupyter notebook is a web-based notebook environment for interactive
computing.

![Jupyter notebook example](docs/resources/running_code_med.png "Jupyter notebook example")
![Jupyter notebook example](docs/resources/running_code_med.png 'Jupyter notebook example')

## Maintained versions

Expand Down
8 changes: 6 additions & 2 deletions binder/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
"outputs": [],
"source": [
"from ipywidgets import IntSlider\n",
"\n",
"slider = IntSlider()\n",
"slider"
]
Expand Down Expand Up @@ -228,12 +229,15 @@
"outputs": [],
"source": [
"from IPython.display import Latex\n",
"Latex(r\"\"\"\\begin{eqnarray}\n",
"\n",
"Latex(\n",
" r\"\"\"\\begin{eqnarray}\n",
"\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n",
"\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n",
"\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n",
"\\end{eqnarray}\"\"\")"
"\\end{eqnarray}\"\"\"\n",
")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions buildutils/src/release-bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ commander

// Bump the version.
let pySpec = spec;
if (spec == 'release') {
if (spec === 'release') {
if (prev.indexOf('a') !== -1) {
pySpec = 'beta';
} else if (prev.indexOf('b') !== -1) {
Expand All @@ -120,7 +120,7 @@ commander
} else {
pySpec = 'alpha';
}
} else if (spec == 'build') {
} else if (spec === 'build') {
if (prev.indexOf('a') !== -1) {
pySpec = 'a';
} else if (prev.indexOf('b') !== -1) {
Expand Down
26 changes: 15 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import logging
import os
import shutil
import sys

logger = logging.getLogger(__name__)
logging.basicConfig()

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

# DEBUG for RTD
print("DEBUG:: sys.path")
print("================")
logger.info("DEBUG:: sys.path")
logger.info("================")
for item in sys.path:
print(item)
logger.info(item)

# add repo root to sys.path
# here = root/docs/source
Expand All @@ -38,15 +42,15 @@
# Copy the contributing file here
shutil.copy(os.path.join(repo_root, "CONTRIBUTING.md"), os.path.join(here, "contributing.md"))

print("repo_root")
print("=====================")
print(repo_root)
logger.info("repo_root")
logger.info("=====================")
logger.info(repo_root)

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

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

Expand Down Expand Up @@ -86,7 +90,7 @@

# General information about the project.
project = "Jupyter Notebook"
copyright = "2015, Jupyter Team, https://jupyter.org"
copyright = "2015, Jupyter Team, https://jupyter.org" # noqa
author = "The Jupyter Team"

# ghissue config
Expand All @@ -98,7 +102,7 @@
#
_version_py = os.path.join(here, "../../notebook/_version.py")
version_ns = {}
exec(compile(open(_version_py).read(), _version_py, "exec"), version_ns)
exec(compile(open(_version_py).read(), _version_py, "exec"), version_ns) # noqa
# The short X.Y version.
version = "%i.%i" % version_ns["version_info"][:2]
# The full version, including alpha/beta/rc tags.
Expand Down
Loading