From be56fd0070766ffdd5c247ac5ca48ecc9a93817b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 1 Apr 2022 18:46:29 -0500 Subject: [PATCH 1/3] adopt pre-commit --- .pre-commit-config.yaml | 74 +++++++++++++++++++++++++++++++++++++ docs/format_description.rst | 16 ++++---- setup.py | 23 +++++------- 3 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..f02ddd75 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,74 @@ +ci: + skip: [check-jsonschema] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + # - id: end-of-file-fixer + # - id: check-case-conflict + # - id: check-executables-have-shebangs + # - id: requirements-txt-fixer + - id: check-added-large-files + # - id: check-case-conflict + # - id: check-toml + # - id: check-yaml + # - id: debug-statements + # - id: forbid-new-submodules + # - id: check-builtin-literals + # - id: trailing-whitespace + + # - repo: https://github.com/psf/black + # rev: 22.3.0 + # hooks: + # - id: black + # args: ["--line-length", "100"] + + # - repo: https://github.com/PyCQA/isort + # rev: 5.10.1 + # hooks: + # - id: isort + # files: \.py$ + # args: [--profile=black] + + # - repo: https://github.com/pre-commit/mirrors-prettier + # rev: v2.6.1 + # hooks: + # - id: prettier + + # - repo: https://github.com/asottile/pyupgrade + # rev: v2.31.1 + # hooks: + # - id: pyupgrade + # args: [--py37-plus] + + - repo: https://github.com/PyCQA/doc8 + rev: 0.11.0 + hooks: + - id: doc8 + args: [--max-line-length=200] + + # - repo: https://github.com/pycqa/flake8 + # rev: 4.0.1 + # hooks: + # - id: flake8 + # additional_dependencies: + # [ + # "flake8-bugbear==20.1.4", + # "flake8-logging-format==0.6.0", + # "flake8-implicit-str-concat==0.2.0", + # ] + + # - repo: https://github.com/pre-commit/mirrors-eslint + # rev: v8.12.0 + # hooks: + # - id: eslint + + - repo: https://github.com/sirosen/check-jsonschema + rev: 0.14.1 + hooks: + - id: check-jsonschema + name: "Check GitHub Workflows" + files: ^\.github/workflows/ + types: [yaml] + args: ["--schemafile", "https://json.schemastore.org/github-workflow"] diff --git a/docs/format_description.rst b/docs/format_description.rst index 1f829599..769edc38 100644 --- a/docs/format_description.rst +++ b/docs/format_description.rst @@ -253,18 +253,16 @@ adding only a ``execution_count`` field, which must be an integer. error ***** -Failed execution may show a traceback - -.. sourcecode:: python +Failed execution may show an error:: { - 'output_type': 'error', - 'ename' : str, # Exception name, as a string - 'evalue' : str, # Exception value, as a string + 'output_type': 'error', + 'ename' : str, # Exception name, as a string + 'evalue' : str, # Exception value, as a string - # The traceback will contain a list of frames, - # represented each as a string. - 'traceback' : list, + # The traceback will contain a list of frames, + # represented each as a string. + 'traceback' : list, } .. versionchanged:: nbformat 4.0 diff --git a/setup.py b/setup.py index 44cced2b..adb80a8d 100644 --- a/setup.py +++ b/setup.py @@ -5,23 +5,14 @@ # Distributed under the terms of the Modified BSD License. from __future__ import print_function +import subprocess +import os +import sys +from glob import glob # the name of the project name = 'nbformat' -#----------------------------------------------------------------------------- -# Minimal Python version sanity check -#----------------------------------------------------------------------------- - -import sys - -#----------------------------------------------------------------------------- -# get on with it -#----------------------------------------------------------------------------- - -import os -from glob import glob - from distutils.core import setup pjoin = os.path.join @@ -82,6 +73,10 @@ if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv): import setuptools + subprocess.run([sys.executable, "-m", "pre_commit", "install"]) + subprocess.run( + [sys.executable, "-m", "pre_commit", "install", "--hook-type", "pre-push"] + ) setuptools_args = {} install_requires = setuptools_args['install_requires'] = [ @@ -92,7 +87,7 @@ extras_require = setuptools_args['extras_require'] = { 'fast': ['fastjsonschema'], - 'test': ['check-manifest', 'fastjsonschema', 'testpath', 'pytest'], + 'test': ['check-manifest', 'fastjsonschema', 'testpath', 'pytest', 'pre-commit'], } if 'setuptools' in sys.modules: From e50996366a999573e9560f6d2f10f4683e456eda Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 1 Apr 2022 18:50:32 -0500 Subject: [PATCH 2/3] fix manifest --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index fb8702ca..9de064ba 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,6 +9,7 @@ recursive-include nbformat *.txt recursive-include nbformat *.json recursive-include tests *.* exclude scripts/jupyter-trust +exclude .pre-commmit-config.yaml # Javascript include package.json From 98a72cc834fa4fce774ba8df7160785884506d7c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 1 Apr 2022 18:54:35 -0500 Subject: [PATCH 3/3] fix manifest --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 9de064ba..f0946b57 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,7 +9,7 @@ recursive-include nbformat *.txt recursive-include nbformat *.json recursive-include tests *.* exclude scripts/jupyter-trust -exclude .pre-commmit-config.yaml +exclude .pre-commit-config.yaml # Javascript include package.json