Skip to content

Commit 4dc3033

Browse files
authored
Adopt ruff and address lint (#1046)
1 parent f38738d commit 4dc3033

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+222
-208
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
version: 2
22
updates:
3-
# Set update schedule for GitHub Actions
43
- package-ecosystem: "github-actions"
54
directory: "/"
65
schedule:
7-
# Check for updates to GitHub Actions every weekday
6+
interval: "weekly"
7+
- package-ecosystem: "pip"
8+
directory: "/"
9+
schedule:
810
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ jobs:
6666
cd $HOME
6767
python -m ipykernel_launcher --help
6868
69-
pre_commit:
69+
test_lint:
70+
name: Test Lint
7071
runs-on: ubuntu-latest
7172
steps:
7273
- uses: actions/checkout@v3
7374
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
74-
- uses: jupyterlab/maintainer-tools/.github/actions/pre-commit@v1
75+
- name: Run Linters
76+
run: |
77+
hatch run typing:test
78+
hatch run lint:style
79+
pipx run 'validate-pyproject[all]' pyproject.toml
80+
pipx run doc8 --max-line-length=200
7581
7682
check_release:
7783
runs-on: ubuntu-latest
@@ -177,7 +183,7 @@ jobs:
177183
- test_docs
178184
- test_without_debugpy
179185
- test_miniumum_versions
180-
- pre_commit
186+
- test_lint
181187
- test_prereleases
182188
- check_release
183189
- link_check

.pre-commit-config.yaml

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
14
repos:
25
- repo: https://github.com/pre-commit/pre-commit-hooks
36
rev: v4.4.0
@@ -10,88 +13,27 @@ repos:
1013
- id: check-case-conflict
1114
- id: check-toml
1215
- id: check-yaml
13-
- id: debug-statements
14-
exclude: ipykernel/kernelapp.py
1516
- id: forbid-new-submodules
1617
- id: check-builtin-literals
1718
- id: trailing-whitespace
1819

19-
- repo: https://github.com/psf/black
20-
rev: 22.10.0
21-
hooks:
22-
- id: black
23-
args: ["--line-length", "100"]
24-
25-
- repo: https://github.com/Carreau/velin
26-
rev: 0.0.12
27-
hooks:
28-
- id: velin
29-
args: ["ipykernel"]
30-
31-
- repo: https://github.com/PyCQA/isort
32-
rev: 5.10.1
33-
hooks:
34-
- id: isort
35-
files: \.py$
36-
args: [--profile=black]
37-
38-
- repo: https://github.com/abravalheri/validate-pyproject
39-
rev: v0.10.1
20+
- repo: https://github.com/python-jsonschema/check-jsonschema
21+
rev: 0.19.2
4022
hooks:
41-
- id: validate-pyproject
42-
stages: [manual]
23+
- id: check-github-workflows
4324

4425
- repo: https://github.com/executablebooks/mdformat
4526
rev: 0.7.16
4627
hooks:
4728
- id: mdformat
48-
additional_dependencies:
49-
[mdformat-gfm, mdformat-frontmatter, mdformat-footnote]
5029

51-
- repo: https://github.com/asottile/pyupgrade
52-
rev: v3.3.0
53-
hooks:
54-
- id: pyupgrade
55-
args: [--py38-plus]
56-
57-
- repo: https://github.com/PyCQA/doc8
58-
rev: v1.0.0
59-
hooks:
60-
- id: doc8
61-
args: [--max-line-length=200]
62-
stages: [manual]
63-
64-
- repo: https://github.com/pre-commit/mirrors-mypy
65-
rev: v0.991
66-
hooks:
67-
- id: mypy
68-
exclude: "ipykernel.*tests"
69-
args: ["--config-file", "pyproject.toml"]
70-
additional_dependencies:
71-
[tornado, jupyter_client, pytest, traitlets, jupyter_core]
72-
stages: [manual]
73-
74-
- repo: https://github.com/john-hen/Flake8-pyproject
75-
rev: 1.2.2
76-
hooks:
77-
- id: Flake8-pyproject
78-
alias: flake8
79-
additional_dependencies:
80-
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0"]
81-
stages: [manual]
82-
83-
- repo: https://github.com/pre-commit/mirrors-eslint
84-
rev: v8.29.0
30+
- repo: https://github.com/psf/black
31+
rev: 22.10.0
8532
hooks:
86-
- id: eslint
87-
stages: [manual]
33+
- id: black
8834

89-
- repo: https://github.com/sirosen/check-jsonschema
90-
rev: 0.19.2
35+
- repo: https://github.com/charliermarsh/ruff-pre-commit
36+
rev: v0.0.165
9137
hooks:
92-
- id: check-jsonschema
93-
name: "Check GitHub Workflows"
94-
files: ^\.github/workflows/
95-
types: [yaml]
96-
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
97-
stages: [manual]
38+
- id: ruff
39+
args: ["--fix"]

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
here = os.path.dirname(__file__)
6767
version_py = os.path.join(here, os.pardir, "ipykernel", "_version.py")
6868
with open(version_py) as f:
69-
exec(compile(f.read(), version_py, "exec"), version_ns)
69+
exec(compile(f.read(), version_py, "exec"), version_ns) # noqa
7070

7171
# The short X.Y version.
7272
version = "%i.%i" % version_ns["version_info"][:2]

examples/embedding/inprocess_qtconsole.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def init_asyncio_patch():
3030
import asyncio
3131

3232
try:
33-
from asyncio import (
34-
WindowsProactorEventLoopPolicy,
35-
WindowsSelectorEventLoopPolicy,
36-
)
33+
from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy
3734
except ImportError:
3835
pass
3936
# not affected

examples/embedding/inprocess_terminal.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ def init_asyncio_patch():
3030
import asyncio
3131

3232
try:
33-
from asyncio import (
34-
WindowsProactorEventLoopPolicy,
35-
WindowsSelectorEventLoopPolicy,
36-
)
33+
from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy
3734
except ImportError:
3835
pass
3936
# not affected

examples/embedding/internal_ipkernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def mpl_kernel(gui):
1919
[
2020
"python",
2121
"--matplotlib=%s" % gui,
22-
#'--log-level=10' # noqa
22+
#'--log-level=10'
2323
]
2424
)
2525
return kernel

examples/embedding/ipkernel_wxapp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import wx
2525
from internal_ipkernel import InternalIPKernel
2626

27+
2728
# -----------------------------------------------------------------------------
2829
# Functions and classes
2930
# -----------------------------------------------------------------------------

ipykernel/_eventloop_macos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def C(classname):
7575
CFRunLoopAddTimer.restype = None
7676
CFRunLoopAddTimer.argtypes = [void_p, void_p, void_p]
7777

78-
kCFRunLoopCommonModes = void_p.in_dll(CoreFoundation, "kCFRunLoopCommonModes")
78+
kCFRunLoopCommonModes = void_p.in_dll(CoreFoundation, "kCFRunLoopCommonModes") # noqa
7979

8080

8181
def _NSApp():

ipykernel/comm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__all__ = ["Comm", "CommManager"]
22

3-
from .comm import Comm # noqa
3+
from .comm import Comm
44
from .manager import CommManager

0 commit comments

Comments
 (0)