-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit configuration, some new checks and reformat (#50)
* Add flake8 configuration * Add pyproject.toml * Remove max line length from make files * Run Black * Fix End of Files * Trim trailing whitespace * Pretty format JSON * Add pre-commit configuration * Update the GH Actions workflow to run pre-commit * Add various Problem Matchers * Update Flake8 URL to github * Downgrade formatter version for black's required-version * fix python-version, update actions, add required-version * bump version * reformat! * fortunately, this will be squashed... --------- Co-authored-by: jack1142 <[email protected]> Co-authored-by: Neuro Assassin <[email protected]>
- Loading branch information
1 parent
75d9c45
commit 6ad4ec4
Showing
67 changed files
with
508 additions
and
274 deletions.
There are no files selected for viewing
This file contains 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,4 @@ | ||
[flake8] | ||
max-line-length = 99 | ||
select = E9,F7,F82 | ||
extend-exclude=.venv/,.stubs/ |
This file was deleted.
Oops, something went wrong.
This file contains 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,17 @@ | ||
{ | ||
"__comment": "Credits to: https://github.com/home-assistant/core/blob/d32c364d7f9e138e0dd9363b34b3cb39f4afcd06/.github/workflows/matchers/check-json.json", | ||
"problemMatcher": [ | ||
{ | ||
"owner": "check-json", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):\\s(Failed to json decode\\s.+\\sline\\s(\\d+)\\scolumn\\s(\\d+).+)$", | ||
"file": 1, | ||
"message": 2, | ||
"line": 3, | ||
"column": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains 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,16 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "check-toml", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+\\.toml):\\s(.+line\\s(\\d+)\\scolumn\\s(\\d+).+)$", | ||
"file": 1, | ||
"message": 2, | ||
"line": 3, | ||
"column": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains 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,19 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "check-yaml", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+)$", | ||
"message": 1 | ||
}, | ||
{ | ||
"regexp": "^ in \"(.+\\.ya?ml)\", line (\\d+), column (\\d+)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains 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,32 @@ | ||
{ | ||
"__comment": "Credits to: https://github.com/home-assistant/core/blob/d32c364d7f9e138e0dd9363b34b3cb39f4afcd06/.github/workflows/matchers/flake8.json", | ||
"problemMatcher": [ | ||
{ | ||
"owner": "flake8-error", | ||
"severity": "error", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):(\\d+):\\s(([EF]\\d{3})\\s.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4, | ||
"code": 5 | ||
} | ||
] | ||
}, | ||
{ | ||
"owner": "flake8-warning", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):(\\d+):\\s(([CDNW]\\d{3})\\s.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains 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,41 @@ | ||
name: Run pre-commit | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
run_precommit: | ||
name: Run pre-commit | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout repository | ||
- uses: actions/checkout@v3 | ||
|
||
# Setup Python and install pre-commit | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.8" | ||
- name: Install pre-commit | ||
run: | | ||
pip install -U pre-commit | ||
# Load cached pre-commit environment | ||
- name: set PY | ||
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pre-commit | ||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} | ||
|
||
# Register problem matchers | ||
- name: Register problem matchers | ||
run: | | ||
echo "::add-matcher::.github/workflows/matchers/check-json.json" | ||
echo "::add-matcher::.github/workflows/matchers/check-toml.json" | ||
echo "::add-matcher::.github/workflows/matchers/check-yaml.json" | ||
echo "::add-matcher::.github/workflows/matchers/flake8.json" | ||
# Run pre-commit | ||
- name: Run pre-commit | ||
run: | | ||
pre-commit run --show-diff-on-failure --color=never --all-files --verbose |
This file was deleted.
Oops, something went wrong.
This file contains 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,55 @@ | ||
default_language_version: | ||
python: python3.8 | ||
exclude: ^.stubs/ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 'refs/tags/23.7.0:refs/tags/23.7.0' | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker | ||
rev: 'v1.1.3' | ||
hooks: | ||
- id: black-disable-checker | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: '6.1.0' | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
# `.gitattributes` should technically already handle this | ||
# but autocrlf can result in local files keeping the CRLF | ||
# which is problematic for codespell | ||
- id: end-of-file-fixer | ||
# normally you would want this but Neuro is not very consistent :P | ||
# - id: mixed-line-ending | ||
# args: | ||
# - "--fix=lf" | ||
|
||
# Trailing whitespace is evil | ||
- id: trailing-whitespace | ||
|
||
# Require literal syntax when initializing builtin types | ||
- id: check-builtin-literals | ||
|
||
# Ensure that links to code on GitHub use the permalinks | ||
- id: check-vcs-permalinks | ||
|
||
# Syntax validation | ||
- id: check-ast | ||
- id: check-json | ||
- id: check-toml | ||
# can be switched to yamllint when this issue gets resolved: | ||
# https://github.com/adrienverge/yamllint/issues/238 | ||
- id: check-yaml | ||
|
||
# JSON auto-formatter | ||
- id: pretty-format-json | ||
args: | ||
- "--autofix" | ||
- "--indent=4" | ||
- "--no-sort-keys" | ||
|
||
# Checks for git-related issues | ||
- id: check-case-conflict | ||
- id: check-merge-conflict |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
], | ||
"requirements": [], | ||
"hidden": false | ||
} | ||
} |
This file contains 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,10 +1,17 @@ | ||
{ | ||
"author" : ["Neuro Assassin"], | ||
"install_msg" : "Thank you for downloading this cog. In-message shortcuts are disabled by guild by default. An administrator can change this rule by running `[p]color msgshort true`", | ||
"name" : "color", | ||
"short" : "Tells you the hexadecimal values, rgb values and names of colors", | ||
"description" : "This cog will tell you the hexadecimal value, rgb value and the name of the color that is supplied to it.", | ||
"tags" : ["tools"], | ||
"requirements" : ["colour", "pillow"], | ||
"hidden" : false | ||
} | ||
"author": [ | ||
"Neuro Assassin" | ||
], | ||
"install_msg": "Thank you for downloading this cog. In-message shortcuts are disabled by guild by default. An administrator can change this rule by running `[p]color msgshort true`", | ||
"name": "color", | ||
"short": "Tells you the hexadecimal values, rgb values and names of colors", | ||
"description": "This cog will tell you the hexadecimal value, rgb value and the name of the color that is supplied to it.", | ||
"tags": [ | ||
"tools" | ||
], | ||
"requirements": [ | ||
"colour", | ||
"pillow" | ||
], | ||
"hidden": false | ||
} |
This file contains 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 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,10 +1,16 @@ | ||
{ | ||
"author" : ["Neuro Assassin"], | ||
"install_msg" : "Thank you for downloading this cog.", | ||
"name" : "commandchart", | ||
"short" : "Tells the used and usages of commands! Based off of aikaterna's chatchart cog.", | ||
"description" : "This cog tells a Discord User the commands used, and the usage of them, in the last so and so messages. Based off of aikaterna's chatchart cog.", | ||
"tags" : ["tools"], | ||
"requirements" : ["matplotlib"], | ||
"hidden" : false | ||
} | ||
"author": [ | ||
"Neuro Assassin" | ||
], | ||
"install_msg": "Thank you for downloading this cog.", | ||
"name": "commandchart", | ||
"short": "Tells the used and usages of commands! Based off of aikaterna's chatchart cog.", | ||
"description": "This cog tells a Discord User the commands used, and the usage of them, in the last so and so messages. Based off of aikaterna's chatchart cog.", | ||
"tags": [ | ||
"tools" | ||
], | ||
"requirements": [ | ||
"matplotlib" | ||
], | ||
"hidden": false | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
"tools" | ||
], | ||
"hidden": false | ||
} | ||
} |
This file contains 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
Oops, something went wrong.