Skip to content

Commit 6efee94

Browse files
authored
Merge pull request #255 from blink1073/use-precommit
2 parents 0c5da2f + ee2b956 commit 6efee94

40 files changed

+1689
-1466
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Initial pre-commit reformat
2+
d6a8168b9f6b8a28bba5f7cca3d6a9c31da041b6

.github/workflows/codeql-analysis.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ name: "CodeQL"
1414

1515
on:
1616
push:
17-
branches: [ master ]
17+
branches: [master]
1818
pull_request:
1919
# The branches below must be a subset of the branches above
20-
branches: [ master ]
20+
branches: [master]
2121
schedule:
22-
- cron: '41 6 * * 6'
22+
# Make a pass every Saturday at 06:41 UTC
23+
- cron: "41 6 * * 6"
2324

2425
permissions:
25-
security-events:
26-
write
26+
security-events: write
2727

2828
jobs:
2929
analyze:
@@ -33,41 +33,41 @@ jobs:
3333
strategy:
3434
fail-fast: false
3535
matrix:
36-
language: ['python' ]
36+
language: ["python"]
3737
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
3838
# Learn more...
3939
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
4040

4141
steps:
42-
- name: Checkout repository
43-
uses: actions/checkout@v2
42+
- name: Checkout repository
43+
uses: actions/checkout@v2
4444

45-
# Initializes the CodeQL tools for scanning.
46-
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v1
48-
with:
49-
languages: ${{ matrix.language }}
50-
# If you wish to specify custom queries, you can do so here or in a config file.
51-
# By default, queries listed here will override any specified in a config file.
52-
# Prefix the list here with "+" to use these queries and those in the config file.
53-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
54-
queries: security-and-quality
45+
# Initializes the CodeQL tools for scanning.
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@v1
48+
with:
49+
languages: ${{ matrix.language }}
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
54+
queries: security-and-quality
5555

56-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57-
# If this step fails, then you should remove it and run the build manually (see below)
58-
- name: Autobuild
59-
uses: github/codeql-action/autobuild@v1
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
- name: Autobuild
59+
uses: github/codeql-action/autobuild@v1
6060

61-
# ℹ️ Command-line programs to run using the OS shell.
62-
# 📚 https://git.io/JvXDl
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 https://git.io/JvXDl
6363

64-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
65-
# and modify them (or add more) to build your code if your project
66-
# uses a compiled language
64+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
65+
# and modify them (or add more) to build your code if your project
66+
# uses a compiled language
6767

68-
#- run: |
69-
# make bootstrap
70-
# make release
68+
#- run: |
69+
# make bootstrap
70+
# make release
7171

72-
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@v1
72+
- name: Perform CodeQL Analysis
73+
uses: github/codeql-action/analyze@v1

.github/workflows/test.yml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ name: Python package
55

66
on:
77
push:
8-
branches: '*'
98
pull_request:
10-
branches: [ master ]
9+
branches: ["master"]
1110

1211
jobs:
1312
build:
14-
1513
runs-on: ${{ matrix.os }}
1614
strategy:
1715
fail-fast: false
@@ -23,29 +21,33 @@ jobs:
2321
- os: windows-latest
2422
python-version: 3.10-dev
2523
steps:
26-
- uses: actions/checkout@v2
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v2
29-
with:
30-
python-version: ${{ matrix.python-version }}
31-
- name: Get pip cache dir
32-
id: pip-cache
33-
run: |
34-
echo "::set-output name=dir::$(pip cache dir)"
35-
- name: pip cache
36-
uses: actions/cache@v2
37-
with:
38-
path: ${{ steps.pip-cache.outputs.dir }}
39-
key: |
40-
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('dev-requirements.txt', 'setup.cfg') }}
41-
restore-keys: |
42-
${{ runner.os }}-pip-${{ matrix.python-version }}-
43-
${{ runner.os }}-pip-
44-
- name: Install dependencies
45-
run: |
46-
python -m pip install --upgrade pip
47-
pip install --upgrade setuptools wheel
48-
pip install -r dev-requirements.txt .
49-
- name: Test with pytest
50-
run: |
51-
pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered
24+
- uses: actions/checkout@v2
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Get pip cache dir
30+
id: pip-cache
31+
run: |
32+
echo "::set-output name=dir::$(pip cache dir)"
33+
- name: pip cache
34+
uses: actions/cache@v2
35+
with:
36+
path: ${{ steps.pip-cache.outputs.dir }}
37+
key: |
38+
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('dev-requirements.txt', 'setup.cfg') }}
39+
restore-keys: |
40+
${{ runner.os }}-pip-${{ matrix.python-version }}-
41+
${{ runner.os }}-pip-
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install --upgrade pip
45+
pip install --upgrade setuptools wheel
46+
pip install -r dev-requirements.txt .
47+
- name: Test with pytest
48+
run: |
49+
pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered
50+
- name: Check manifest
51+
run: |
52+
pip install check-manifest
53+
check-manifest -v

.pre-commit-config.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
ci:
2+
skip: [check-jsonschema]
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.1.0
7+
hooks:
8+
- id: debug-statements
9+
- id: end-of-file-fixer
10+
- id: check-case-conflict
11+
- id: check-executables-have-shebangs
12+
- id: requirements-txt-fixer
13+
- id: check-added-large-files
14+
- id: check-case-conflict
15+
- id: check-toml
16+
- id: check-yaml
17+
- id: forbid-new-submodules
18+
- id: check-builtin-literals
19+
- id: trailing-whitespace
20+
21+
- repo: https://github.com/psf/black
22+
rev: 22.3.0
23+
hooks:
24+
- id: black
25+
args: ["--line-length", "100"]
26+
27+
- repo: https://github.com/PyCQA/isort
28+
rev: 5.10.1
29+
hooks:
30+
- id: isort
31+
files: \.py$
32+
args: [--profile=black]
33+
34+
- repo: https://github.com/pre-commit/mirrors-prettier
35+
rev: v2.6.2
36+
hooks:
37+
- id: prettier
38+
39+
- repo: https://github.com/asottile/pyupgrade
40+
rev: v2.31.1
41+
hooks:
42+
- id: pyupgrade
43+
args: [--py37-plus]
44+
45+
- repo: https://github.com/PyCQA/doc8
46+
rev: 0.11.1
47+
hooks:
48+
- id: doc8
49+
args: [--max-line-length=200]
50+
51+
# - repo: https://github.com/pycqa/flake8
52+
# rev: 4.0.1
53+
# hooks:
54+
# - id: flake8
55+
# additional_dependencies:
56+
# [
57+
# "flake8-bugbear==20.1.4",
58+
# "flake8-logging-format==0.6.0",
59+
# "flake8-implicit-str-concat==0.2.0",
60+
# ]
61+
62+
# - repo: https://github.com/pre-commit/mirrors-mypy
63+
# rev: v0.942
64+
# hooks:
65+
# - id: mypy
66+
67+
- repo: https://github.com/sirosen/check-jsonschema
68+
rev: 0.14.2
69+
hooks:
70+
- id: check-jsonschema
71+
name: "Check GitHub Workflows"
72+
files: ^\.github/workflows/
73+
types: [yaml]
74+
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

COPYING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ software without specific prior written permission.
2424
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2525
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2626
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
27+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
2828
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2929
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
3030
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
@@ -35,7 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3535
## About the Jupyter Development Team
3636

3737
The Jupyter Development Team is the set of all contributors to the Jupyter
38-
project. This includes all of the Jupyter subprojects. A full list with
38+
project. This includes all of the Jupyter subprojects. A full list with
3939
details is kept in the documentation directory, in the file
4040
`about/credits.txt`.
4141

@@ -48,8 +48,8 @@ Jupyter uses a shared copyright model. Each contributor maintains copyright
4848
over their contributions to Jupyter. It is important to note that these
4949
contributions are typically only changes to the repositories. Thus, the Jupyter
5050
source code in its entirety is not the copyright of any single person or
51-
institution. Instead, it is the collective copyright of the entire Jupyter
52-
Development Team. If individual contributors want to maintain a record of what
51+
institution. Instead, it is the collective copyright of the entire Jupyter
52+
Development Team. If individual contributors want to maintain a record of what
5353
changes/contributions they have specific copyright on, they should indicate
5454
their copyright in the commit message of the change, when they commit the
5555
change to one of the Jupyter repositories.

MANIFEST.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ include CONTRIBUTING.md
33
include README.md
44
include dev-requirements.txt
55

6+
exclude .pre-commit-config.yaml
7+
exclude .git-blame-ignore-revs
8+
exclude readthedocs.yml
9+
610
# Documentation
711
graft docs
812
graft examples
@@ -11,7 +15,8 @@ graft examples
1115
graft jupyter_core/tests/dotipython
1216
graft jupyter_core/tests/dotipython_empty
1317

14-
# docs subdirs we want to skip
18+
# dirs we want to skip
19+
prune scripts
1520
prune docs/_build
1621

1722
# Patterns to exclude from any directory

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Core common functionality of Jupyter projects.
55
This package contains base application classes and configuration inherited by other projects.
66
It doesn't do much on its own.
77

8-
98
# Development Setup
109

1110
The [Jupyter Contributor Guides](http://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html) provide extensive information on contributing code or documentation to Jupyter projects. The limited instructions below for setting up a development environment are for your convenience.
@@ -23,6 +22,38 @@ and download the dependencies of code and test suite by executing:
2322

2423
The last command runs the test suite to verify the setup. During development, you can pass filenames to `py.test`, and it will execute only those tests.
2524

25+
## Code Styling
26+
27+
`jupyter_core` has adopted automatic code formatting so you shouldn't
28+
need to worry too much about your code style.
29+
As long as your code is valid,
30+
the pre-commit hook should take care of how it should look.
31+
`pre-commit` and its associated hooks will automatically be installed when
32+
you run `pip install -e ".[test]"`
33+
34+
To install `pre-commit` manually, run the following:
35+
36+
```bash
37+
pip install pre-commit
38+
pre-commit install
39+
```
40+
41+
You can invoke the pre-commit hook by hand at any time with:
42+
43+
```bash
44+
pre-commit run
45+
```
46+
47+
which should run any autoformatting on your code
48+
and tell you about any errors it couldn't fix automatically.
49+
You may also install [black integration](https://github.com/psf/black#editor-integration)
50+
into your text editor to format code automatically.
51+
52+
If you have already committed files before setting up the pre-commit
53+
hook with `pre-commit install`, you can fix everything up using
54+
`pre-commit run --all-files`. You need to make the fixing commit
55+
yourself after that.
56+
2657
## Documentation
2758

2859
The documentation of Jupyter Core is generated from the files in `docs/` using Sphinx. Instructions for setting up Sphinx with a selection of optional modules are in the [Documentation Guide](http://jupyter.readthedocs.io/en/latest/contrib_docs/index.html). You'll also need the `make` command.
@@ -37,5 +68,4 @@ The following commands build the documentation in HTML format and check for brok
3768

3869
Point your browser to the following URL to access the generated documentation:
3970

40-
_file:///my/projects/jupyter\_core/docs/\_build/html/index.html_
41-
71+
_file:///my/projects/jupyter_core/docs/\_build/html/index.html_

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ipykernel
2+
pre-commit
23
pytest
34
pytest-cov
45
pytest-timeout

docs/changelog.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ See the `jupyter_core
3333
4.9 <https://github.com/jupyter/jupyter_core/milestone/21?closed=1>`__
3434
milestone on GitHub for the full list of pull requests and issues closed.
3535

36-
- Add Python site user base subdirectories to config and data user-level paths if ``site.ENABLE_USER_SITE`` is True. One way to disable these directory additions is to set the ``PYTHONNOUSERSITE`` environment variable. These locations can be customized by setting the ``PYTHONUSERBASE`` environment variable. (:ghpull:`242`)
36+
- Add Python site user base subdirectories to config and data user-level paths
37+
if ``site.ENABLE_USER_SITE`` is True. One way to disable these directory
38+
additions is to set the ``PYTHONNOUSERSITE`` environment variable. These
39+
locations can be customized by setting the ``PYTHONUSERBASE`` environment
40+
variable. (:ghpull:`242`)
3741

3842

3943
4.8
@@ -44,7 +48,10 @@ milestone on GitHub for the full list of pull requests and issues closed.
4448
`on
4549
GitHub <https://github.com/jupyter/jupyter_core/releases/tag/4.8.2>`__
4650

47-
jupyter_core 4.8.1 was released the same day as 4.8.0 and also included the fix below for the Windows tests. Unfortunately, the 4.8.1 release commit and tag were not pushed to GitHub. We are releasing 4.8.2 so we have a commit and tag in version control.
51+
jupyter_core 4.8.1 was released the same day as 4.8.0 and also included the fix
52+
below for the Windows tests. Unfortunately, the 4.8.1 release commit and tag
53+
were not pushed to GitHub. We are releasing 4.8.2 so we have a commit and tag
54+
in version control.
4855

4956
- Fix windows test regression (:ghpull:`240`)
5057

@@ -89,7 +96,13 @@ See the `jupyter_core
8996
4.7 <https://github.com/jupyter/jupyter_core/milestone/19?closed=1>`__
9097
milestone on GitHub for the full list of pull requests and issues closed.
9198

92-
- Add a new ``JUPYTER_PREFER_ENV_PATH`` variable, which can be set to switch the order of the environment-level path and the user-level path in the Jupyter path hierarchy (e.g., ``jupyter --paths``). It is considered set if it is a value that is not one of 'no', 'n', 'off', 'false', '0', or '0.0' (case insensitive). If you are running Jupyter in multiple virtual environments as the same user, you will likely want to set this environment variable.
99+
- Add a new ``JUPYTER_PREFER_ENV_PATH`` variable, which can be set to switch
100+
the order of the environment-level path and the user-level path in the
101+
Jupyter path hierarchy (e.g., ``jupyter --paths``). It is considered set if
102+
it is a value that is not one of 'no', 'n', 'off', 'false', '0', or '0.0'
103+
(case insensitive). If you are running Jupyter in multiple virtual
104+
environments as the same user, you will likely want to set this environment
105+
variable.
93106
- Drop Python 2.x and 3.5 support, as they have reached end of life.
94107
- Add Python 3.9 builds to testing, and expand testing to cover Windows, macOS, and Linux platforms.
95108
- ``jupyter --paths --debug`` now explains the environment variables that affect the current path list.

0 commit comments

Comments
 (0)