Skip to content

Commit a9c39b3

Browse files
committed
set up pre-commit
1 parent 5ae1159 commit a9c39b3

File tree

7 files changed

+136
-6
lines changed

7 files changed

+136
-6
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+
42fe3bb4188a1fbd1810674776e7855cd529b8fc

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ name: Python package
55

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

1211
jobs:
1312
build:
@@ -49,3 +48,7 @@ jobs:
4948
- name: Test with pytest
5049
run: |
5150
pytest -vv jupyter_core --timeout 60 --cov jupyter_core --cov-report term-missing:skip-covered
51+
- name: Check manifest
52+
run: |
53+
pip install check-manifest
54+
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-eslint
63+
# rev: v8.12.0
64+
# hooks:
65+
# - id: eslint
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"]

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ and download the dependencies of code and test suite by executing:
2323

2424
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.
2525

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

2860
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.

dev-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ ipykernel
22
pytest
33
pytest-cov
44
pytest-timeout
5+
pre-commit

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)