Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit with more hooks #136

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/nikola.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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/[email protected]
52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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/'

1 change: 0 additions & 1 deletion check_checksums.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ def main(fname):

if __name__ == "__main__":
main('pages/checksums.rst')

4 changes: 2 additions & 2 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

NAVIGATION_LINKS = {
DEFAULT_LANG: (

(
(
('/features.html', 'What is PyPy?'),
Expand All @@ -111,7 +111,7 @@
),
'Blog',
),

(
(
('https://twitter.com/pypyproject', 'Twitter'),
Expand Down
2 changes: 0 additions & 2 deletions confrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ class Project(Project):
Page = PyPyPage
def get_docpath(self):
return self.mydir


2 changes: 1 addition & 1 deletion plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Plugin modules go here.
# Plugin modules go here.
4 changes: 2 additions & 2 deletions plugins/static_comments/static_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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
Expand Down
Empty file modified posts/2022/10/get_hackernews_stats.py
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.codespell]
ignore-words-list = "gameboy,ist,nd,openend,theses"
quiet-level = 3
skip = "*.html,*.js,./.*,./archive/*,./venv_nikola,archive/*"