Skip to content

Commit

Permalink
feat: make modules use black formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Aug 29, 2024
1 parent aaff4f4 commit 4e8a88f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
3 changes: 3 additions & 0 deletions {{ cookiecutter.__repo_name }}/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["ms-python.black-formatter", "BdSoftware.format-on-auto-save"]
}
14 changes: 14 additions & 0 deletions {{ cookiecutter.__repo_name }}/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// To allow formatting on autosave you need to install the
// "Format on Auto Save" extension
// https://github.com/microsoft/vscode/issues/45997#issuecomment-950405496
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
},
"files.autoSave": "afterDelay",
"editor.rulers": [
88
],

}
23 changes: 21 additions & 2 deletions {{ cookiecutter.__repo_name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

{{cookiecutter.description}}

## Usage

To launch it, first install the package then run [deepaas](https://github.com/ai4os/DEEPaaS):
```bash
git clone {{ cookiecutter.git_base_url }}/{{ cookiecutter.__repo_name }}
Expand All @@ -11,6 +13,23 @@ pip install -e .
deepaas-run --listen-ip 0.0.0.0
```

## Contributing

This module tries to enforce best practices by using [Black](https://github.com/psf/black)
to format the code.

For an optimal development experience, we recommend installing the VScode extensions
[Black](https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter)
and [Format on Auto Save](https://marketplace.visualstudio.com/items?itemName=BdSoftware.format-on-auto-save).
Their configurations are automatically included in the [`.vscode`](./.vscode) folder.
This will format the code during the automatic saves, though you can force formatting with
`CTRL + Shift + I` (or `CTRL + S` to save).

To enable them only for this repository: after installing, click `Disable`,
then click `Enable (workspace)`.

In the Black _global_ settings, we also recommend setting `black-formatter.showNotification = off`.

## Project structure
```
Expand Down Expand Up @@ -40,13 +59,13 @@ deepaas-run --listen-ip 0.0.0.0
├── data/ <- Folder to store the data
├── models/ <- Folder to store models
├── tests/ <- Scripts to perfrom code testing
|
├── metadata.json <- Metadata information propagated to the AI4OS Hub
├── pyproject.toml <- a configuration file used by packaging tools, so {{cookiecutter.__app_name}}
│ can be imported or installed with `pip install -e .`
│ can be imported or installed with `pip install -e .`
├── requirements.txt <- The requirements file for reproducing the analysis environment, i.e.
│ contains a list of packages needed to make {{cookiecutter.__app_name}} work
Expand Down
5 changes: 3 additions & 2 deletions {{ cookiecutter.__repo_name }}/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ envdir = {toxworkdir}/shared
commands = pytest --numprocesses=auto {posargs}
allowlist_externals =
mkdir
passenv =
passenv =
RCLONERCLONE_CONFIG_RSHARE_VENDOR
RCLONE_CONFIG
RCLONE_CONFIG_RSHARE_PASS
Expand All @@ -23,8 +23,9 @@ deps = -r{toxinidir}/requirements-test.txt

# important for Jenkins publishing of results: store results in subdirectory
[testenv:qc.sty]
commands =
commands =
flake8 --statistics --tee --output-file={toxinidir}/flake8.log \
--max-line-length=80 --extend-select=B950 --extend-ignore=E203,E501,E701 \ # add this line to support Black formatter
--format=pylint {{ cookiecutter.__app_name }} tests

# important for Jenkins publishing of results: store results in subdirectory
Expand Down

0 comments on commit 4e8a88f

Please sign in to comment.