-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCONTRIBUTING
112 lines (70 loc) · 4.91 KB
/
CONTRIBUTING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Contributing
I welcome all contributions to the `sirtuin` project! By contributing, you help improve the tools and resources available to the community.
## Community Guidelines
1. Be respectful and considerate in your interactions.
2. Provide constructive feedback.
3. Be open to feedback on your contributions.
## How to Contribute
### Reporting Bugs
If you find a bug in the project, please create an issue on GitHub with detailed information about the bug, how to reproduce it, and any relevant screenshots or logs.
### Suggesting Enhancements
If you have an idea for an enhancement or new feature, please create an issue on GitHub with a detailed description of the enhancement, the motivation behind it, and any potential implementation ideas.
### Pull Requests
1. **Fork the Repository**: Create a personal fork of the project on GitHub.
2. **Clone Your Fork**: Clone your fork to your local machine.
3. **Create a Branch:** Create a new branch for your feature or bug fix.
4. **Make Changes:** Make your changes to the codebase.
5. **Commit Changes:** Commit your changes with a clear and descriptive commit message.
6. **Push Changes:** Push your changes to your fork.
7. **Create Pull Request:** Create a pull request from your forked repository to the main repository, describing your changes in detail.
## IDE Recommendations
I recommend working with VSCode, an IDE that does not need to be presented. Internally, I use a set of code extensions enabling a minimum of code standardization, making the life of many developers more enjoyable. Those extensions are given in `.vscode/extensions.json`, and can be downloaded directly via the VSCode extension store. This goes hand and hand with properly configured VSCode workspace settings, available in `.vscode/settings.json`.
## Code Quality
### Return Statements:
A comment that will come back often in PR reviews is the spacing in your code. The overall strategy is to split your code by functional blocks, aka adding empty lines to differentiate loops, if-statements or clusters of similar actions. There are also a few more guidelines:
1. Return statements should be isolated from any code blocks
2. Do not use spacing betIen a function name and the first line of code
An application of those guidelines is illustrated below:
```python
# do
def function():
return object
# don't
def function():
return object
# do
def function():
object = get_object()
return object
# don't
def function():
object = get_object()
return object
```
### Assert Statements:
The guidelines are the same for `assert` statements than they are for `return` statements.
### Helpers:
I use Python 3.12 so make sure to install a clean venv environment depending on a 3.12.\* version. I rely on [poetry](https://python-poetry.org/) for environment management.
I use some packages to help with code quality, those are:
- [black](https://pypi.org/project/black/) configured in `pyproject.toml`
- [ruff](https://pypi.org/project/ruff/) configured in `pyproject.toml`
- [mypy](https://pypi.org/project/mypy/) configured in `pyproject.toml`
### Naming Conventions:
"There are only two hard things in Computer Science: cache invalidation and naming things." - Phil Karlton
That is exactly why it is important everyone follow guidelines regarding naming conventions, especially when moving quickly as a team. Here are a set of rules that will most likely guide you through any problem you would face:
1. Do not use abbreviations
2. Use at least 2 words for function names
3. Boolean variables should be infered from their name (e.g. start with `is_` or `has_`)
4. Use `snake_case` for folder names, function names
5. Use `PascalCase` for class names
6. Use `SCREAMING_SNAKE_CASE` for constants
7. Use `_` prefix for private functions
### Typing:
Typing is key to maintainability. It will increase the readability of the code, but will also passively document your code. Finally, type checking will help to find some obvious bugs.
I rely on dynamic typing via [Pydantic](https://pydantic-docs.helpmanual.io/) and use static typing via VSCode for now. To enable static typing, ensure that you are using the VSCode extension [Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance).
Static typing is handled via the help of [mypy](https://pydantic-docs.helpmanual.io/mypy_plugin/).
## Git Conventions
### Branches:
I have a simple convention for branch naming: `{initials}/{descriptive-kebab-case}`. Keep them all lowercase. For John Doe working on a feature A, that would be `jd/feature-a`.
### Commits:
The Conventional Commits specification is a light convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages. Learn more [here](https://www.conventionalcommits.org/en/v1.0.0/).