Skip to content

Commit

Permalink
style: Adds bandit, autoflake & precommits (#173)
Browse files Browse the repository at this point in the history
* chore: Added autoflake & bandit

* docs: Updated makefile

* ci: Adds jobs for bandit

* chore: Adds precommit

* chore: Adds precommit config

* docs: Updates dev install instructions

* style: Fixes llinting

* chore: Updates precommit config
  • Loading branch information
frgfm authored Oct 25, 2023
1 parent 5dfa4da commit 59600d0
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ body:
- type: markdown
attributes:
value: >
Thanks for helping us improve the library!
Thanks for helping us improve the library!
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ body:
- type: markdown
attributes:
value: >
Thanks for contributing 🎉
Thanks for contributing 🎉
2 changes: 1 addition & 1 deletion .github/workflows/doc-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
shell: python
env:
STATUS: ${{ github.event.build.status }}
ERROR: ${{ github.event.build.error.message }}
ERROR: ${{ github.event.build.error.message }}
19 changes: 19 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,22 @@ jobs:
pip install black
black --version
black --check --diff .
bandit:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run bandit
run: |
pip install bandit[toml]
bandit --version
bandit -r . -c pyproject.toml
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
exclude: ^.conda/
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ As a contributor, you will only have to ensure coverage of your code by adding a

### Feature requests & bug report

Whether you encountered a problem, or you have a feature suggestion, your input has value and can be used by contributors to reference it in their developments. For this purpose, we advise you to use Github [issues](https://github.com/pyronear/pyro-vision/issues).
Whether you encountered a problem, or you have a feature suggestion, your input has value and can be used by contributors to reference it in their developments. For this purpose, we advise you to use Github [issues](https://github.com/pyronear/pyro-vision/issues).

First, check whether the topic wasn't already covered in an open / closed issue. If not, feel free to open a new one! When doing so, use issue templates whenever possible and provide enough information for other contributors to jump in.

Expand Down Expand Up @@ -61,6 +61,7 @@ git checkout -b a-short-description
4 - You only have to set your development environment now. First uninstall any existing installation of the library with `pip uninstall pyrovision`, then:
```shell
pip install -e ".[dev]"
pre-commit install
```


Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ quality:
mypy
pydocstyle
black --check .
bandit -r . -c pyproject.toml
autoflake -r .

# this target runs checks on all files and potentially modifies some of them
style:
isort .
black .
autoflake --in-place -r .

# Run tests for the library
test:
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ quality = [
"mypy>=0.812",
"pydocstyle[toml]>=6.0.0",
"black>=22.1,<23.0",
"bandit[toml]>=1.7.0,<1.8.0",
"autoflake>=1.5.0,<2.0.0",
"pre-commit>=2.17.0,<3.0.0",
]
docs = [
"sphinx>=3.0.0,!=3.5.0",
Expand All @@ -75,6 +78,9 @@ dev = [
"mypy>=0.812",
"pydocstyle[toml]>=6.0.0",
"black>=22.1,<23.0",
"bandit[toml]>=1.7.0,<1.8.0",
"autoflake>=1.5.0,<2.0.0",
"pre-commit>=2.17.0,<3.0.0",
# docs
"sphinx>=3.0.0,!=3.5.0",
"furo>=2022.3.4",
Expand Down Expand Up @@ -132,3 +138,12 @@ source = ["pyrovision"]
[tool.black]
line-length = 120
target-version = ['py38']

[tool.autoflake]
remove-unused-variables = true
remove-all-unused-imports = true
ignore-init-module-imports = true

[tool.bandit]
exclude_dirs = [".github/collect_env.py"]
skips = ["B101"]
2 changes: 1 addition & 1 deletion references/classification/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Image classification

The goal here is to propose a training script and a dataset to train a wildfire classification model.
The goal here is to propose a training script and a dataset to train a wildfire classification model.

## Setup

Expand Down
2 changes: 1 addition & 1 deletion references/classification/results.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ rexnet1_5x,"(256, 384)",pad,openfire,0.2036,0.0759
mobilenet_v3_small,"(224, 224)",squish,openfire,0.2785,0.0967
mobilenet_v3_large,"(224, 224)",squish,openfire,0.2689,0.1077
resnet18,"(224, 224)",squish,openfire,0.2353,0.0796
resnet34,"(224, 224)",squish,openfire,0.2748,0.1126
resnet34,"(224, 224)",squish,openfire,0.2748,0.1126

0 comments on commit 59600d0

Please sign in to comment.