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

Update pre commit hooks #1774

Merged
merged 7 commits into from
Sep 11, 2021
Merged
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
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[flake8]
exclude = .eggs,build,docs,.venv*
ignore = E203 E501 W503 W504
per-file-ignores =
praw/models/__init__.py:F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even go as far as to do
praw/*/__init__.py

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine as is.

praw/models/listing/mixins/__init__.py:F401
praw/models/reddit/mixins/__init__.py:F401
19 changes: 19 additions & 0 deletions .github/workflows/pre-commit_autoupdate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: browniebroke/pre-commit-autoupdate-action@main
- uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "Update pre-commit hooks"
body: Update versions of pre-commit hooks to the latest version.
name: 'Update pre-commit hooks'
on:
schedule:
- cron: '0 15 * * 1'
workflow_dispatch:
1 change: 0 additions & 1 deletion .github/workflows/tag_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ on:
branches:
- master
- release_test

67 changes: 61 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,62 @@
fail_fast: true
repos:
- hooks:
- id: black
language_version: python3
repo: https://github.com/psf/black
rev: 20.8b1

- repo: https://github.com/pre-commit/pre-commit-hooks
hooks:
- id: end-of-file-fixer
exclude: .*\.txt
rev: v4.0.1

- repo: local
hooks:
- id: static_word_checks
args:
- '--replace'
entry: python -m tools.static_word_checks
language: system
name: Static Word Checks
pass_filenames: false
types: [ python ]

- id: check_documentation
entry: python -m tools.check_documentation
language: system
name: Check Documentation
pass_filenames: false
types: [ python ]

- repo: https://github.com/psf/black
hooks:
- id: black
language_version: python3
rev: 21.7b0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to make this work without setting the value rev?
It would add technical debt..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's set by pre-commit autoupdate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requiring hooks to have pinned versions is a core design decision of pre-commit, since it ensures that all developers and CIs get the same consistent version of hooks for a given project repository commit, and thus hooks don't arbitrarily fail or make different changes based on whatever version happens to be installed on the current platform. There's also a GH action that, like dependabot, automatically submits PRs at a reasonable frequency to upgrade out of date hooks.


- repo: https://github.com/LilSpazJoekp/docstrfmt
hooks:
- id: docstrfmt
rev: v1.4.0

- repo: https://github.com/pycqa/flake8
hooks:
- id: flake8
rev: 3.9.2

- repo: https://github.com/ikamensh/flynt/
hooks:
- id: flynt
args:
- '-ll'
- '1000'
- '-tc'
language_version: python3.8
rev: '0.66'

- repo: https://github.com/pycqa/isort
hooks:
- id: isort
rev: 5.9.3

- repo: https://github.com/pycqa/pydocstyle
hooks:
- id: pydocstyle
files: praw/.*
rev: 6.1.1
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sys.path.insert(0, ".")
sys.path.insert(1, "..")

from praw import __version__
from praw import __version__ # noqa: E402

copyright = datetime.today().strftime("%Y, Bryce Boe")
exclude_patterns = ["_build"]
Expand Down
4 changes: 2 additions & 2 deletions pre_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run_static():
success &= do_process(["flynt", "-q", "-tc", "-ll", "1000", "."])
# needs to be first because flynt is not black compliant
success &= do_process(["black", "."])
success &= do_process(["docstrfmt", "-e", "docs/examples", "."])
success &= do_process(["docstrfmt", "."])
success &= do_process(["isort", "."])
# Linters
success &= do_process(
Expand All @@ -61,7 +61,7 @@ def run_static():
path.join(current_directory, "tools", "check_documentation.py"),
]
)
success &= do_process(["flake8", "--exclude=.eggs,build,docs,.venv*"])
success &= do_process(["flake8"])
success &= do_process(["pydocstyle", "praw"])
# success &= do_process(["pylint", "--rcfile=.pylintrc", "praw"])

Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[tool.black]
exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv.*|_build|buck-out|build|dist)/'
extend_exclude = '/(\.venv.*)/'
line-length = 88

[tool.docstrfmt]
extend_exclude = ['./docs/examples/']

[tool.isort]
profile = "black"
skip_glob = '.venv*'
profile = 'black'
skip_glob = '.venv*'
7 changes: 0 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
[aliases]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the purpose of the setup.cfg here if you already have tox.ini giving instructions on the test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is settings for setuptools.

Copy link
Contributor

@CAM-Gerlach CAM-Gerlach Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this setting and setup.py test is deprecated and will trigger a warning in new versions of setuptools, and will eventually be removed.

test = pytest

[flake8]
ignore = E203 W503
per-file-ignores =
praw/models/__init__.py:F401
praw/models/listing/mixins/__init__.py:F401
praw/models/reddit/mixins/__init__.py:F401
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,4 @@
}
],
"recorded_with": "betamax/0.8.1"
}
}