Skip to content
Snippets Groups Projects
Commit e49079d3 authored by Benedikt's avatar Benedikt
Browse files

Merge branch 'docs/#36_code_guide' into 'devel'

Code guidelines

See merge request !5
parents 82aa6fda 6c87135e
Branches
Tags v0.3.0
1 merge request!5Code guidelines
Pipeline #56620 passed
# Coding Guide
Here lies all the guidelines regarding the code development for **dccQuantities**.
- [Python Style Guide](#python-style-guide)
- [Development workflow](#development-workflow)
---
## Python Style Guide
**dccQuantities** follows the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html) excepting the following deviations.
### 2 Python Language Rules
#### 2.1 Lint
Instead of `pylint`, run `ruff` over your code with the set of rules defined at `ruff.toml`.
This change is decided as `pylint` is quite slower, as well as `ruff` not only allows defining more rules but also formating the code.
**Lint suppression**: No warning should be suppressed, unless there is a valid and discussed reason to do so.
If any warning requires to be suppressed, a revision of the `ruff.toml` configuration might be required.
### 3 Python Style Rules
#### 3.2 Line length
Maximum line length is _120 characters_.
The exceptions to this rule are the ones defined at the original guidelines.
#### 3.3 Parentheses
Avoid using parenthesis for redundant packing/unpacking.
**Yes:**
```python
for ham, spam in iterable:
...
return foo, bar
```
**No:**
```python
for (ham, spam) in iterable:
...
return (foo, bar)
```
#### 3.8 Comments and Docstrings
##### 3.8.1 Docstrings
All docstrings should follow the [NumPyDocs conventions](https://numpydoc.readthedocs.io/en/latest/format.html), with the same line length as the one defined for the general code.
A docstring should be organized as a summary line (one physical line not exceeding 80 characters) terminated by a period, question mark, or exclamation point.
When writing more (encouraged), this must be followed by a blank line, followed by the rest of the docstring starting at the same cursor position as the first quote of the first line.
---
## Development workflow
All changes must pass a review process through a pull-request.
The general guidelines for this process are defined at [`CONTRIBUTING.md`](CONTRIBUTING.md).
### General changes
It is defined as "general changes" those that can be labelled with the tag `feature/`, `bugfix/` or `docs/`.
The branches for these changes are created **from 'devel'** and **_squash merged_ into 'devel'**.
![general_pull_request](doc/imgs/general_pr.png)
After merging, other branches also created from 'devel' should be updated by **rebasing onto 'devel'**.
### Hotfixes
A **hotfix** correlates to code changes that must be integrated immediately at the latest release, with no window to wait to be resolved with the unreleased changes.
The branches for these changes are created **from 'main'** and **_squash merged_ into 'main'**.
> Note: Hotfixes must update the PATCH number at the version within the pull request.
![hotfix_pull_request](doc/imgs/hotfix_pr.png)
After merging, the branch 'devel' should be updated by **rebasing onto 'main'**.
### Releases
**Release branches** put together all unreleased changes to be included into the 'main' branch.
A release branch should contain only a 'bump version' commit, and it must be created **from the latest 'devel'** and **_merged_ into 'main'**.
![release_pull_request](doc/imgs/release_pr.png)
After merging, the branch 'main' should be **merged into 'devel'**.
doc/imgs/general_pr.png

16.5 KiB

doc/imgs/hotfix_pr.png

22.8 KiB

doc/imgs/release_pr.png

23.8 KiB

# Enforcing line length greater than 88:
line-length = 120
# Ruff report as a concise list of all issues:
output-format = "concise"
[format]
docstring-code-format = true
skip-magic-trailing-comma = true
[lint]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"D", # pydocstyle
"DOC", # pydoclint
"E", # pycodestyle error
"F", # Pyflakes
"FA", # flake8-future-annotations
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest
"RET", # flake8-return
"RUF", # Ruff-specific rules
"SIM", # flake8-simplify
"TC", # flake8-type-checking
"W", # pycodestyle warning
]
ignore = [
"ANN002", # missing type for *args
"ANN003", # missing type for **kwargs
"D401", # first line in docstring as imperative mood
"PLR6301", # no-self-use
"PLR0913", # too-many-arguments
"PLR0904", # too-many-public-methods
"PLR0916", # too-many-boolean-expressions
"PLR0912", # too-many-branches
"PLR0904", # too-many-public-methods
"PLR0911", # too-many-return-statements
"PLR0915", # too-many-statements
]
preview = true
[lint.flake8-annotations]
allow-star-arg-any = true
mypy-init-return = true
suppress-none-returning = true
[lint.flake8-unused-arguments]
ignore-variadic-names = true
[lint.isort]
split-on-trailing-comma=false
[lint.pycodestyle]
ignore-overlong-task-comments = true
[lint.pydocstyle]
convention = "numpy"
[lint.pylint]
max-args = 10
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment