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

Add pre-commit configuration #756

Closed
wants to merge 4 commits 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
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exclude: "node_modules|.venv|isso/tests"
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't we want tests formatted correctly as well?


repos:
- repo: meta
hooks:
- id: check-hooks-apply

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-executables-have-shebangs
Copy link
Member

Choose a reason for hiding this comment

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

We don't have any bash scripts afaik

- id: check-case-conflict
- id: check-yaml
Copy link
Member

Choose a reason for hiding this comment

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

Do we have YAML files apart from the ansible example?

args: [--unsafe]
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
language: python
files: ^isso/.*\.py$
Copy link
Member

Choose a reason for hiding this comment

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

Will this catch isso/foo/bar.py as well? I'm not familiar with the regexp(?) engine that interprets this, but will .* match subfolders (slashes) too?

types: [python]
args: ["--config=setup.cfg", "--select=E9,F63,F7,F82"]
Copy link
Member

Choose a reason for hiding this comment

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

isn't this severely limiting what errors we'll get?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not to be too frustrating at the time of the commit or a PR.
If you prefer, we can enlarge this selection or apply everything.


# Specific part for https://pre-commit.ci
Copy link
Member

Choose a reason for hiding this comment

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

Am I understanding this correctly that there'll be a little bot auto-committing to this repo? I'd rather avoid this. Proposing changes is fine, but commit rights seem a bit overkill.
Or will this only auto-commit what it thinks are fixes to the branches of PR authors which we can then squash?

ci:
autofix_prs: true
autoupdate_schedule: quarterly
skip: [
"check-hooks-apply"
]
submodules: false
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def run(self):
"Programming Language :: Python :: 3.9"
],
install_requires=requires,
extras_require={
"dev": [
"pre-commit>=2.15,<2.18",
"flake8>4,<4.1",
],
},
entry_points={
'console_scripts':
['isso = isso:main'],
Expand Down