diff --git a/.github/workflows/nikola.yml b/.github/workflows/nikola.yml index cb2af90ac..ea556d6ce 100644 --- a/.github/workflows/nikola.yml +++ b/.github/workflows/nikola.yml @@ -20,11 +20,6 @@ jobs: - name: Check valid checksums shell: bash run: python3 check_checksums.py - - name: Look for typos with codespell - shell: bash - run: | - pip install --user codespell[toml] - codespell --ignore-words-list=gameboy,ist,mata,nd,openend,theses --quiet=3 --skip="./archive/*,*.html,*.js" - name: Build docs shell: bash run: | @@ -37,3 +32,12 @@ jobs: # reuse the venv venv_nikola/bin/python -m pip install ghp-import venv_nikola/bin/ghp-import -m"Automatic push by ghp-import" -f -p -r origin -b gh-pages --cname=pypy.org public + + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..00db3c560 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,52 @@ +# Learn more about this config here: https://pre-commit.com/ + +# To enable these pre-commit hooks run: +# `pipx install pre-commit` or `brew install pre-commit` +# Then in the project root directory run `pre-commit install` + +# default_language_version: +# python: python3 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-builtin-literals + - id: check-byte-order-marker + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-toml + - id: check-vcs-permalinks + exclude: ".*1424098117108093942.html$" + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + types: [python] + - id: file-contents-sorter + - id: fix-byte-order-marker + - id: forbid-new-submodules + - id: forbid-submodules + - id: mixed-line-ending + - id: name-tests-test + - id: pretty-format-json + - id: requirements-txt-fixer + - id: sort-simple-yaml + - id: trailing-whitespace + types: [python] + + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: ["--toml=pyproject.toml"] + additional_dependencies: + - tomli diff --git a/Makefile b/Makefile index 6acbc8114..952e3267d 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ all: build venv_nikola/bin/nikola: ## create a virtualenv to build the website > @virtualenv -ppython3 ./venv_nikola -> @venv_nikola/bin/python -mpip install nikola==8.2.2 markdown==3.3 jinja2 aiohttp watchdog ruamel.yaml feedparser codespell +> @venv_nikola/bin/python -mpip install nikola==8.2.2 markdown==3.3 jinja2 aiohttp watchdog ruamel.yaml feedparser codespell tomli > @venv_nikola/bin/nikola plugin -i sidebar > @venv_nikola/bin/nikola plugin -i localsearch @@ -25,7 +25,7 @@ plugins/import_blogger: venv_nikola/bin/nikola codespell: venv_nikola/bin/nikola ## check and fix typos # If codespell is not found, rerun `make venv_nikola/bin/nikola` -> venv_nikola/bin/codespell --ignore-words-list=gameboy,ist,mata,nd,openend,theses --quiet=3 --skip="./venv_nikola/*,./archive/*,*.html,*.js,./public" --write-changes +> venv_nikola/bin/codespell --toml=pyproject.toml --write-changes build: codespell ## build the website if needed, the result is in ./public > venv_nikola/bin/nikola build @@ -60,4 +60,3 @@ help: ## Show this help. > @echo "\nHelp for building the website, based on nikola" > @echo "Possible commands are:" > @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\(.*\):.*##\(.*\)/ \1: \2/' - diff --git a/check_checksums.py b/check_checksums.py old mode 100644 new mode 100755 index 6b8ecc6ae..f0605cb59 --- a/check_checksums.py +++ b/check_checksums.py @@ -11,4 +11,3 @@ def main(fname): if __name__ == "__main__": main('pages/checksums.rst') - diff --git a/conf.py b/conf.py index 830b780f7..ffe7bb1b7 100644 --- a/conf.py +++ b/conf.py @@ -90,7 +90,7 @@ NAVIGATION_LINKS = { DEFAULT_LANG: ( - + ( ( ('/features.html', 'What is PyPy?'), @@ -111,7 +111,7 @@ ), 'Blog', ), - + ( ( ('https://twitter.com/pypyproject', 'Twitter'), diff --git a/confrest.py b/confrest.py index 4f15f66ea..22866531a 100644 --- a/confrest.py +++ b/confrest.py @@ -34,5 +34,3 @@ class Project(Project): Page = PyPyPage def get_docpath(self): return self.mydir - - diff --git a/plugins/__init__.py b/plugins/__init__.py index fd7e25d79..e45b1d872 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -1 +1 @@ -# Plugin modules go here. \ No newline at end of file +# Plugin modules go here. diff --git a/plugins/static_comments/static_comments.py b/plugins/static_comments/static_comments.py index 5a0f249c3..158d184d4 100644 --- a/plugins/static_comments/static_comments.py +++ b/plugins/static_comments/static_comments.py @@ -211,7 +211,7 @@ def _scan_comments(self, path, file, owner): # make sure this is a comment to "file" if not filename[1:].startswith(post_base + '-comment'): continue - # There is both a *.mata and a *.html. Send only the base of + # There is both a *.meta and a *.html. Send only the base of # the *.meta for parsing parts = filename.rsplit('.', 1) if parts[1] != 'meta': @@ -243,7 +243,7 @@ def _process_comments(self, comments): """Given a list of comments, rearranges them according to hierarchy and returns ordered list with indentation information.""" # First, build tree structure out of TreeNode with comments attached root_list = [] - comment_nodes = dict() + comment_nodes = {} for comment in comments: node = utils.TreeNode(comment.id) node.comment = comment diff --git a/posts/2022/10/get_hackernews_stats.py b/posts/2022/10/get_hackernews_stats.py old mode 100644 new mode 100755 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..21281d379 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.codespell] +ignore-words-list = "gameboy,ist,nd,openend,theses" +quiet-level = 3 +skip = "*.html,*.js,./.*,./archive/*,./venv_nikola,archive/*"