Skip to content

Commit

Permalink
Restore usage of flake8 and add to CI (#316)
Browse files Browse the repository at this point in the history
* Restore flake8 configuration

* Fix f-strings missing placeholders

* Fix undefined local with import star

* Fix end of file should have one empty line

* Fix trailing whitespace

* Add pre-commit hooks

* Add lint step to CI

* Add pre-commit and hatch to dev dependencies

* Add linting contributing instructions

* Fix CI failure for old actions/cache version

* Ignore duplicate files in wheel
  • Loading branch information
danyeaw authored Feb 7, 2025
1 parent dafc920 commit b36454a
Show file tree
Hide file tree
Showing 169 changed files with 971 additions and 931 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
{
"presets": ["es2015"],
}
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory": "nbclassic/static/components"
}
}
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
builtins = c, get_config
exclude =
.cache,
.github,
docs,
.venv,
dist,
build
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ Paste the output from your command line running `jupyter nbclassic` here, use `-
Paste the output from your browser Javascript console here, if applicable.

</pre>
</details>
</details>
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: Is this a common issue? See our Docs.
url: https://nbclassic.readthedocs.io/en/latest/troubleshooting.html#what-to-do-when-things-go-wrong
about: Before opening an issue, make sure your issue hasn't already been addressed in the documentation.
about: Before opening an issue, make sure your issue hasn't already been addressed in the documentation.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Finally, please answer the following questions for yourself before submitting an
<!-- Add any other context or screenshots about the feature request here. You can also include links to examples of other programs that have something similar to your request. For example:
* Another project [...] solved this by [...]
-->
-->
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
pip install -e .
- name: Check Release
if: ${{ matrix.group == 'check_release' }}
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
version_spec: 100.100.100
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ on:
pull_request:

jobs:
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.13'
- name: Lint with Pre-commit
uses: pre-commit/[email protected]
build:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pycqa/flake8
rev: 'e43806be3607110919eff72939fda031776e885a' # frozen: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
31 changes: 29 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,33 @@ running other instances of Jupyter NbClassic. You can try the following steps:
a port that is neither the default nor in use, then it should be fine.
5. Verify the installation with the steps in the previous section.

Code Formatting and Linting
^^^^^^^^^^^^^^^^^^^^^^^^^^^

All source code is linted using `Flake8 <https://github.com/PyCQA/flake8>`_. When
code is modified and committed, staged files are automatically checked for PEP 8
compliance using pre-commit git hooks (with help from `pre-commit
<https://github.com/pre-commit/pre-commit>`_). Using a linter like `flake8` helps
maintain consistent code style and catches potential errors during pull request
reviews, streamlining the review process. Other checks are also run to look for
proper new lines at the end of files and to remove unnecessary whitespace.

To install `pre-commit`, run::

pip install -e ".[dev]"
pre-commit install

You can manually trigger the pre-commit hook at any time with::

pre-commit run

This will check your code against the pre-commit checks and report any style
violations or potential issues.

If you committed files before setting up the pre-commit hook with
`pre-commit install`, you can check all files using
`pre-commit run --all-files`. You will need to fix any reported issues and commit
the changes yourself afterward.

Rebuilding JavaScript and CSS
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -137,9 +164,9 @@ To run the Python tests, use::
For the end to end Pytest-Playwright tests you will need to install the browser binaries using::

playwright install

Then you can run the end to end tests using::

pytest -sv nbclassic/tests/end_to_end

If you want coverage statistics as well, you can run::
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ git clean -dffx
python -m build
tbump <new version number>
pip install twine
twine check dist/*
twine check dist/*
twine upload dist/*
```
4 changes: 2 additions & 2 deletions docs-translations/hi-IN/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Google Group](https://img.shields.io/badge/-Google%20Group-lightgrey.svg)](https://groups.google.com/forum/#!forum/jupyter)
[![Build Status](https://travis-ci.org/jupyter/notebook.svg?branch=master)](https://travis-ci.org/jupyter/notebook)
[![Documentation Status](https://readthedocs.org/projects/jupyter-notebook/badge/?version=latest)](https://jupyter-notebook.readthedocs.io/en/stable/?badge=latest)



Jupyter नोटबुक इंटरैक्टिव के लिए एक वेब-आधारित नोटबुक वातावरण है
Expand Down Expand Up @@ -74,4 +74,4 @@ IPython कोडबेस का बिग स्प्लिट ™। IPython
- [Korean Version of Installation](https://github.com/ChungJooHo/Jupyter_Kor_doc/)
- [Documentation for Project Jupyter](https://jupyter.readthedocs.io/en/latest/index.html )
- [Issues](https://github.com/jupyter/nbclassic/issues)
- [Technical support - Jupyter Google Group](https://groups.google.com/forum/#!forum/jupyter)
- [Technical support - Jupyter Google Group](https://groups.google.com/forum/#!forum/jupyter)
2 changes: 1 addition & 1 deletion docs-translations/ja-JP/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Google Group](https://img.shields.io/badge/-Google%20Group-lightgrey.svg)](https://groups.google.com/forum/#!forum/jupyter)
[![Build Status](https://travis-ci.org/jupyter/notebook.svg?branch=master)](https://travis-ci.org/jupyter/notebook)
[![Documentation Status](https://readthedocs.org/projects/jupyter-notebook/badge/?version=latest)](https://jupyter-notebook.readthedocs.io/en/stable/?badge=latest)

英語版のリンク : [[English Version](http://github.com/jupyter/nbclassic/)]

Jupyter Notebookは、インタラクティブなWebベースのノートブック形式の環境です。
Expand Down
18 changes: 7 additions & 11 deletions docs-translations/ko-KR/HowtoRun.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Notebook 실행하기

## 첫 걸음
## 첫 걸음
1. 다음 명령어를 통해 Notebook 서버를 시작하세요 :

$ jupyter notebook
Expand All @@ -9,7 +9,7 @@


# Notebook 서버 시작하기

Notebook을 컴퓨터에 설치하였으면 Notebook 서버를 시작할 수 있습니다. 다음 명령어를 이용하여 Notebook서버를 시작할 수 있습니다.

$ jupyter notebook
Expand All @@ -19,12 +19,12 @@
$ jupyter notebook
$ [I 08:58:24.417 NotebookApp] Serving notebooks from local directory: /Users/catherline
$ [I 08:58:24.417 NotebookApp] 0 active kernels
$ [I 08:58:24.417 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
$ [I 08:58:24.417 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
$ [I 08:58:24.417 NotebookApp] Use Control-C to stop this server and shut down all kernels

기본 브라우저를 통해 이 주소가 열립니다.

Notebook이 브라우저에 열리면, Notebook의 목록을 보여주는 Notebook Dashboard를 볼 수 있습니다. 대체로 가장 상위의 디렉토리를 열어줄 것입니다.
Notebook이 브라우저에 열리면, Notebook의 목록을 보여주는 Notebook Dashboard를 볼 수 있습니다. 대체로 가장 상위의 디렉토리를 열어줄 것입니다.

**Notebook Dashboard**

Expand All @@ -33,9 +33,9 @@
# Notebook 서버의 명령어 소개

## 커스텀 IP 나 포트를 이용하여 시작하려면 어떻게 해야할까?

기본값으로, Notebook 서버는 포트 8888로 시작됩니다. 만약 포트8888이 사용할 수 없다면, Notebook 서버는 다른 가능한 포트를 찾습니다. 또한 임의로 포트를 설정해주는 것도 가능합니다. 예를 들어 포트 9999로 실행하면 :

$ jupyter notebook --port 9999


Expand All @@ -45,13 +45,9 @@

$ jupyter notebook --no-browser


## Notebook 서버 옵션 도움말 보기

Notebook 서버는 --help 옵션을 통해 도움말 메시지를 제공합니다 :

$ jupyter notebook --help




8 changes: 4 additions & 4 deletions docs-translations/ko-KR/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ Python과 Jupyter를 설치할 때 Anaconda를 이용하는 것을 추천합니

새로운 이용자들은 Anaconda를 설치하는 것을 강력하게 추천합니다. Anaconda는 Python과 Jupyter를 쉽게 설치하게 해주고, 과학적인 계산과 데이터를 위한 자주 사용되는 패키지들의 설치에도 유용합니다.

설치 순서 :
설치 순서 :

1. Anaconda를 다운받으세요. Anaconda의 가장 최신의 Python 3버전을 다운 받는 것을 추천합니다.
2. 다운 받은 Anaconda 의 다운로드 페이지에 있는 설명을 읽고 설치해주세요.
3. 축하합니다. Jupyter Notebook 을 설치하셨습니다. Jupyter Notebook을 실행하려면 :

$ jupyter notebook

## 숙련된 Python 이용자 : pip을 통해 설치하기

Python 이용자라면, Anaconda 대신에 Python의 패키지 매니저 pip을 이용하여 설치하세요.

첫째로, 가장 최신의 pip인지를 확인하세요; 구 버전은 독립성에 문제가 있을 수 있습니다.

$ pip install --upgrade pip

이제 다음을 이용하여 Jupyter Notebook를 설치하세요 :
Expand Down
4 changes: 2 additions & 2 deletions docs-translations/ko-KR/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Google Group](https://img.shields.io/badge/-Google%20Group-lightgrey.svg)](https://groups.google.com/forum/#!forum/jupyter)
[![Build Status](https://travis-ci.org/jupyter/notebook.svg?branch=master)](https://travis-ci.org/jupyter/notebook)
[![Documentation Status](https://readthedocs.org/projects/jupyter-notebook/badge/?version=latest)](http://jupyter-notebook.readthedocs.io/en/stable/?badge=stable)

English 버전 링크 : [[English Version](http://github.com/jupyter/nbclassic/)]

Jupyter notebook 은 상호 교환을 위한 웹 기반 환경입니다.
Expand All @@ -25,7 +25,7 @@ You can find the installation documentation for the
조금 더 심화된 Jupyter notebook의 사용은 다음 주소에서 볼 수 있습니다.
[here](https://jupyter-notebook.readthedocs.io/en/stable/).

설치를 위해서는
설치를 위해서는
[pip installed](https://pip.readthedocs.io/en/stable/installing/) 가 있는지 확인한 후 다음을 실행해주세요:

$ pip install notebook
Expand Down
5 changes: 0 additions & 5 deletions docs-translations/ko-KR/UIComponents.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ jupyter notebook 명령어를 실행하면 가장 먼저 Notebook Dashboard가
이제 Notebook Dashboard 안의 Notebook 파일이 아닌 표시된 파일을 선택하여 열어야한다고 한다면, 파일은 파일 편집기로 열립니다.

![File Editor example](resources/file_editor.GIF "File Editor")





4 changes: 2 additions & 2 deletions docs-translations/zh-CN/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Google Group](https://img.shields.io/badge/-Google%20Group-lightgrey.svg)](https://groups.google.com/forum/#!forum/jupyter)
[![Build Status](https://travis-ci.org/jupyter/notebook.svg?branch=master)](https://travis-ci.org/jupyter/notebook)
[![Documentation Status](https://readthedocs.org/projects/jupyter-notebook/badge/?version=latest)](https://jupyter-notebook.readthedocs.io/en/stable/?badge=latest)



Jupyter Notebook是用于交互的基于Web的笔记本环境
Expand Down Expand Up @@ -74,4 +74,4 @@ IPython代码库的Big Split™。 IPython 3是最后一个主要的整体
- [Korean Version of Installation](https://github.com/ChungJooHo/Jupyter_Kor_doc/)
- [Documentation for Project Jupyter](https://jupyter.readthedocs.io/en/latest/index.html )
- [Issues](https://github.com/jupyter/nbclassic/issues)
- [Technical support - Jupyter Google Group](https://groups.google.com/forum/#!forum/jupyter)
- [Technical support - Jupyter Google Group](https://groups.google.com/forum/#!forum/jupyter)
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ linkcheck:
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

spelling:
$(SPHINXBUILD) -b spelling $(ALLSPHINXOPTS) $(BUILDDIR)/spelling
@echo "Spell check complete; look for any errors in the above output " \
Expand Down
4 changes: 2 additions & 2 deletions docs/autogen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
====================================
The notebook server can be run with a variety of command line arguments.
A list of available options can be found below in the :ref:`options section
A list of available options can be found below in the :ref:`options section
<options>`.
Defaults for these options can also be set by creating a file named
Expand All @@ -29,7 +29,7 @@
Options
-------
This list of options can be generated by running the following and hitting
This list of options can be generated by running the following and hitting
enter::
$ jupyter notebook --help
Expand Down
2 changes: 1 addition & 1 deletion docs/jsdoc_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"markdown": {
"parser": "gfm"
},
"plugins": [
"plugins": [
"plugins/markdown" ,
"jsdoc_plugin.js"
],
Expand Down
2 changes: 1 addition & 1 deletion docs/jsdoc_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ exports.handlers = {
}
}
}
};
};
1 change: 0 additions & 1 deletion docs/shimming.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ Here's a snapshot of how JupyterApp's are initialized. The order of operations w
```

## Where do we add the steps above?

4 changes: 2 additions & 2 deletions docs/source/_templates/sidebar-nav-bs-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
font-weight: bold;
}
</style>

<nav class="bd-links" id="bd-docs-nav" aria-label="{{ _('Documentation Contents') }}">
<div class="bd-toc-item navbar-nav">
<!-- Specify a startdepth of 0 instead of default of 1 -->
Expand All @@ -21,4 +21,4 @@
titles_only=True
) }}
</div>
</nav>
</nav>
2 changes: 1 addition & 1 deletion docs/source/config_docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Configuration
security
frontend_config
examples/Notebook/Distributing Jupyter Extensions as Python Packages
extending/index.rst
extending/index.rst
2 changes: 1 addition & 1 deletion docs/source/config_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ front-end NbClassic client (i.e. the familiar notebook interface).
$ jupyter nbclassic --generate-config

:ref:`Command line arguments for configuration <config>` settings are documented in the configuration file and the user documentation.

- Review the section: :ref:`Running a Notebook server <working_remotely>`
- Related: `Configuring a language kernel <https://ipython.readthedocs.io/en/latest/install/kernel_install.html>`_
to run in the Notebook server enables your server to run other languages, like R or Julia.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/utils/list_pyfiles.ipy
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from IPython.display import FileLink, display
files =!ls *.py
for f in files:
display(FileLink(f))
display(FileLink(f))
2 changes: 1 addition & 1 deletion docs/source/examples/utils/list_subdirs.ipy
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ from IPython.display import FileLinks, display
dirs =!ls -d */
for d in dirs:
if d != '__pycache__/':
display(FileLinks(d))
display(FileLinks(d))
Loading

0 comments on commit b36454a

Please sign in to comment.