Unverified Commit 8b068053 authored by Marco Edward Gorelli's avatar Marco Edward Gorelli Committed by GitHub
Browse files

Document jupyter hook (#2416)



This also introduces a script so we can reference the latest version in
the example pre-commit configuration in the docs without forgetting to
update it when doing a release!

Commit history before merge:

* document jupyter hook
* note minimum version
* add check for pre-commit version
* use git tag
* curl api during ci
* parse version from changes file
* fixup script
* rename variables
* Tweak the docs & magical script
* fix couple of typos
* pin additional dependencies in hook
* Add types-PyYAML to lockfile

Co-authored-by: default avatarRichard Si <63936253+ichard26@users.noreply.github.com>
parent 366a0806
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -12,6 +12,14 @@ repos:
        require_serial: true
        types_or: [python, pyi]

      - id: check-pre-commit-rev-in-example
        name: Check pre-commit rev in example
        language: python
        entry: python -m scripts.check_pre_commit_rev_in_example
        files: '(CHANGES\.md|source_version_control\.md)$'
        additional_dependencies:
          ["commonmark==0.9.1", "pyyaml==5.4.1", "beautifulsoup4==4.9.3"]

  - repo: https://gitlab.com/pycqa/flake8
    rev: 3.9.2
    hooks:
@@ -25,6 +33,7 @@ repos:
        exclude: ^docs/conf.py
        additional_dependencies:
          - types-dataclasses >= 0.1.3
          - types-PyYAML
          - tomli >= 0.2.6, < 2.0.0
          - types-typed-ast >= 1.4.1
          - click >= 8.0.0
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ flake8-bugbear = "*"
mypy = ">=0.910"
types-dataclasses = ">=0.1.3"
types-typed-ast = ">=1.4.1"
types-PyYAML = ">=5.4.1"

# Documentation related requirements.
Sphinx = ">=4.1.2"
+20 −4
Original line number Diff line number Diff line
{
    "_meta": {
        "hash": {
            "sha256": "ac07cc9a5cb19ea72381baf4ba0db1689f475538d37e4be3119fc958a722b062"
            "sha256": "ebf216584cfb2c962a1792d0682f3c08b44c7ae27305a03a54eacd6f42df27db"
        },
        "pipfile-spec": 6,
        "requires": {},
@@ -901,6 +901,14 @@
            "markers": "python_version >= '3.6'",
            "version": "==2.0.1"
        },
        "matplotlib-inline": {
            "hashes": [
                "sha256:5cf1176f554abb4fa98cb362aa2b55c500147e4bdbb07e3fda359143e1da0811",
                "sha256:f41d5ff73c9f5385775d5c0bc13b424535c8402fe70ea8210f93e11f3683993e"
            ],
            "markers": "python_version >= '3.5'",
            "version": "==0.1.2"
        },
        "mccabe": {
            "hashes": [
                "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
@@ -1149,7 +1157,7 @@
                "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
                "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
            ],
            "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
            "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
            "version": "==2.4.7"
        },
        "pytest": {
@@ -1340,7 +1348,7 @@
                "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
                "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
            "version": "==1.16.0"
        },
        "snowballstemmer": {
@@ -1435,7 +1443,7 @@
                "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
                "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
            ],
            "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
            "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
            "version": "==0.10.2"
        },
        "tomli": {
@@ -1521,6 +1529,14 @@
            "index": "pypi",
            "version": "==0.1.7"
        },
        "types-pyyaml": {
            "hashes": [
                "sha256:745dcb4b1522423026bcc83abb9925fba747f1e8602d902f71a4058f9e7fb662",
                "sha256:96f8d3d96aa1a18a465e8f6a220e02cff2f52632314845a364ecbacb0aea6e30"
            ],
            "index": "pypi",
            "version": "==5.4.6"
        },
        "types-typed-ast": {
            "hashes": [
                "sha256:b7f561796b4d002c7522b0020f58b18f715bd28a31429d424a78e2e2dbbd6785",
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ following will not be formatted:
  get_ipython().system('ls')
  ```

- invalid syntax, as it can't be safely distinguished from automagics in the absense of
- invalid syntax, as it can't be safely distinguished from automagics in the absence of
  a running `IPython` kernel.

## Why are Flake8's E203 and W503 violated?
+14 −1
Original line number Diff line number Diff line
@@ -7,8 +7,21 @@ Use [pre-commit](https://pre-commit.com/). Once you
```yaml
repos:
  - repo: https://github.com/psf/black
    rev: stable # Replace by any tag/version: https://github.com/psf/black/tags
    rev: 21.7b0
    hooks:
      - id: black
        language_version: python3 # Should be a command that runs python3.6+
```

Feel free to switch out the `rev` value to something else, like another
[tag/version][black-tags] or even a specific commit. Although we discourage the use of
branches or other mutable refs since the hook [won't auto update as you may
expect][pre-commit-mutable-rev].

If you want support for Jupyter Notebooks as well, then replace `id: black` with
`id: black-jupyter` (though note that it's only available from version `21.8b0`
onwards).

[black-tags]: https://github.com/psf/black/tags
[pre-commit-mutable-rev]:
  https://pre-commit.com/#using-the-latest-version-for-a-repository
Loading