-
Notifications
You must be signed in to change notification settings - Fork 3
adding pre-commit with a linting workflow #25
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
Draft
JanAdamiak
wants to merge
1
commit into
pydanny:main
Choose a base branch
from
JanAdamiak:adding-precommit-hooks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Pre-commit linter | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout the current repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Cache pre-commit and Python virtual environment | ||
| id: pre-commit-cache-restore | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| .git/hooks/pre-commit | ||
| py3_yagro_venv | ||
| key: ${{ runner.os }}-lint-${{ hashFiles('**/.pre-commit-config.yaml') }} | ||
|
|
||
| - name: Install pre-commit and all of the necessary hooks | ||
| run: | | ||
| python -m venv py3_yagro_venv | ||
| source py3_yagro_venv/bin/activate | ||
|
|
||
| pip install pre-commit | ||
| pre-commit install --install-hooks | ||
|
|
||
| - name: Run pre-commit hooks | ||
| run: | | ||
| source py3_yagro_venv/bin/activate | ||
| pre-commit run --show-diff-on-failure --all-files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,4 +163,4 @@ cython_debug/ | |
| .vscode/ | ||
| .ruff_cache/ | ||
| changelog.json | ||
| .idea | ||
| .idea | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| default_language_version: | ||
| python: python3 | ||
|
|
||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.4.0 | ||
| hooks: | ||
| - id: check-merge-conflict | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: check-case-conflict | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: check-symlinks | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: end-of-file-fixer | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: trailing-whitespace | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: check-ast | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
| - id: debug-statements | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: check-json | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: pretty-format-json | ||
| args: | ||
| - --autofix | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: check-yaml | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - id: detect-private-key | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - repo: https://github.com/timothycrosley/isort | ||
| rev: 5.12.0 | ||
| hooks: | ||
| - id: isort | ||
| types: | ||
| - file | ||
| - python | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - repo: https://github.com/psf/black | ||
| rev: 23.9.1 | ||
| hooks: | ||
| - id: black | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.0.291 | ||
| hooks: | ||
| - id: ruff | ||
| exclude: > | ||
| (?x)( | ||
| ^{{cookiecutter.slug}}/ | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,23 @@ | ||
| { | ||
| "full_name": "Daniel Roy Greenfeld", | ||
| "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.slug }}", | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bug which will cause Cookiecutter to behave erratically or throw an error. This is because the |
||
| "command_line_interface": [ | ||
| "No", | ||
| "Yes" | ||
| ], | ||
| "email": "[email protected]", | ||
| "full_name": "Daniel Roy Greenfeld", | ||
| "github_username": "pydanny", | ||
| "license": [ | ||
| "MIT", | ||
| "BSD", | ||
| "ISC", | ||
| "Apache Software License 2.0", | ||
| "GNU General Public License v3", | ||
| "Not open source" | ||
| ], | ||
| "project_name": "Python Boilerplate", | ||
| "slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}", | ||
| "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.slug }}", | ||
| "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.", | ||
| "pypi_username": "{{ cookiecutter.github_username }}", | ||
| "command_line_interface": ["No", "Yes"], | ||
| "version": "0.1.0", | ||
| "license": ["MIT", "BSD", "ISC", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"] | ||
| "slug": "{{ cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_') }}", | ||
| "version": "0.1.0" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| # ruff: noqa: F401 | ||
| __author__ = "Daniel Greenfeld" | ||
|
|
||
|
|
||
| from .legacy import rst_to_json, file_opener | ||
| from .legacy import file_opener, rst_to_json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import pathlib | ||
| import json | ||
| import pathlib | ||
|
|
||
|
|
||
| def main(): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ pip install -e '.[test]' | |
|
|
||
| ### Code quality | ||
|
|
||
| ```bash | ||
| ```bash | ||
| make lint | ||
| ``` | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from rich import print | ||
| import typer | ||
| from rich import print | ||
|
|
||
|
|
||
| app = typer.Typer() | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add hook to exclude
cookiecutter.jsonfrom the linting process.