-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add linting and formatting CU-86bw0yqjw (#47)
* Linting and formatting setup using pre-commit * Updated devcontainer with pre-commit
- Loading branch information
1 parent
cc237b5
commit cfbfc22
Showing
7 changed files
with
149 additions
and
15 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
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,9 +1,19 @@ | ||
name: ci | ||
on: [push, pull_request] | ||
on: push | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- uses: pre-commit/[email protected] | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
env: | ||
PORT: "8000" | ||
|
@@ -14,10 +24,10 @@ jobs: | |
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v2 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-central-1 | ||
- name: Set up Python 3.11 | ||
|
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
repos: | ||
# a set of useful Python-based pre-commit hooks | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
# list of definitions and supported hooks: https://pre-commit.com/hooks.html | ||
- id: trailing-whitespace # removes any whitespace at the ends of lines | ||
- id: check-toml # check toml syntax by loading all toml files | ||
- id: check-yaml # check yaml syntax by loading all yaml files | ||
- id: check-json # check-json syntax by loading all json files | ||
- id: check-merge-conflict # check for files with merge conflict strings | ||
args: ["--assume-in-merge"] # and run this check even when not explicitly in a merge | ||
- id: check-added-large-files # check that no "large" files have been added | ||
args: ["--maxkb=10240"] # where large means 10MB+, as in Hugging Face's git server | ||
- id: debug-statements # check for python debug statements (import pdb, breakpoint, etc.) | ||
- id: detect-private-key # checks for private keys (BEGIN X PRIVATE KEY, etc.) | ||
|
||
# black python autoformatting | ||
- repo: https://github.com/psf/black | ||
rev: 23.1.0 | ||
hooks: | ||
- id: black | ||
|
||
# flake8 python linter with all the fixins | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.0.0 | ||
hooks: | ||
# additional configuration of flake8 and extensions in pyproject.toml | ||
- id: flake8 | ||
additional_dependencies: | ||
[ | ||
flake8-annotations, | ||
flake8-bandit, | ||
flake8-bugbear, | ||
flake8-black, | ||
flake8-docstrings, | ||
flake8-import-order, | ||
darglint, | ||
mypy, | ||
pycodestyle, | ||
pydocstyle, | ||
Flake8-pyproject | ||
] | ||
|
||
# removed unused imports and variables | ||
- repo: https://github.com/PyCQA/autoflake | ||
rev: v2.0.1 | ||
hooks: | ||
- id: autoflake | ||
name: autoflake | ||
entry: autoflake | ||
language: python | ||
"types": [python] | ||
require_serial: true | ||
args: | ||
- "--in-place" | ||
- "--expand-star-imports" | ||
- "--remove-duplicate-keys" | ||
- "--remove-unused-variables" | ||
|
||
# add trailing commas to calls and literals | ||
- repo: https://github.com/asottile/add-trailing-comma | ||
rev: v2.4.0 | ||
hooks: | ||
- id: add-trailing-comma | ||
args: | ||
- --py36-plus | ||
|
||
# upgrade syntax for new version of python | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.3.1 | ||
hooks: | ||
- id: pyupgrade | ||
args: | ||
- --py36-plus | ||
|
||
# sort python imports in the right order | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
name: isort (python) |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[project] | ||
name = "Vectorizing" | ||
description = "Utility to vectorize raster images" | ||
readme = "README.md" | ||
packages = [{include = "src"}] | ||
|
||
[tool.black] | ||
line-length = 88 | ||
target-version = ['py311'] | ||
|
||
[tool.flake8] | ||
max-complexity = 12 # complexity checker threshold | ||
max-line-length = 88 | ||
extend-ignore = [ | ||
# import order | ||
'I100', | ||
'I101', | ||
'I202', | ||
] | ||
import-order-style = "google" | ||
docstring-convention = "numpy" | ||
strictness = "short" | ||
docstring-style = "numpy" | ||
suppress-none-returning = true | ||
mypy-init-return = true | ||
|
||
[tool.isort] | ||
profile = "black" |