You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[4.6 To contribute changes](#46-to-contribute-changes)
14
14
*[4.7 How To Report A Bug](#47-how-to-report-a-bug)
15
15
*[4.8 How To Suggest A Feature Or Enhancement](#48-how-to-suggest-a-feature-or-enhancement)
16
-
*[5. Code Review Process](#5-code-review-process)
17
-
*[5.1 Issues](#51-issues)
18
-
*[5.2 Pull Requests](#52-pull-requests)
19
-
*[5.3 Differences between "new features" and "improvements"](#53-differences-between-new-features-and-improvements)
20
-
*[6. Community](#6-community)
16
+
*[5. Community](#5-community)
21
17
22
18
# 1. Introduction
23
19
**Welcome!** First off, thank you for contributing to the further development of Red. We're always looking for new ways to improve our project and we appreciate any help you can give us.
@@ -29,25 +25,25 @@ Red is an open source project. This means that each and every one of the develop
29
25
We love receiving contributions from our community. Any assistance you can provide with regards to bug fixes, feature enhancements, and documentation is more than welcome.
30
26
31
27
# 2. Ground Rules
32
-
1. Ensure cross compatibility for Windows, Mac OS and Linux.
28
+
1. Ensure cross compatibility for Windows, macOS and Linux.
33
29
2. Ensure all Python features used in contributions exist and work in Python 3.8.1 and above.
34
-
3. Create new tests for code you add or bugs you fix. It helps us help you by making sure we don't accidentally break anything :grinning:
30
+
3. If you're working on code that's covered by tests, create new tests for code you add or bugs you fix.
31
+
It helps us help you by making sure we don't accidentally break anything :grinning:
35
32
4. Create any issues for new features you'd like to implement and explain why this feature is useful to everyone and not just you personally.
36
-
5. Don't add new cogs unless specifically given approval in an issue discussing said cog idea.
33
+
5. Don't make Pull Requests adding new functionality if there is no accepted issue discussing said functionality.
37
34
6. Be welcoming to newcomers and encourage diverse new contributors from all backgrounds. See [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/).
38
35
39
36
# 3. Your First Contribution
40
37
Unsure of how to get started contributing to Red? Please take a look at the Issues section of this repo and sort by the following labels:
41
38
42
-
*beginner - issues that can normally be fixed in just a few lines of code and maybe a test or two.
43
-
*help-wanted - issues that are currently unassigned to anyone and may be a bit more involved/complex than issues tagged with beginner.
39
+
*Good First Issue - issues that can normally be fixed in just a few lines of code.
40
+
*Help Wanted - issues that are currently unassigned to anyone and may be a bit more involved/complex than issues tagged with Good First Issue.
44
41
45
42
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github)
46
43
47
-
At this point you're ready to start making changes. Feel free to ask for help; everyone was a beginner at some point!
44
+
At this point you're ready to start making changes. Feel free to ask for help (see information about [Community](#5-community) below); everyone was a beginner at some point!
48
45
49
46
# 4. Getting Started
50
-
51
47
Red's repository is configured to follow a particular development workflow, using various reputable tools. We kindly ask that you stick to this workflow when contributing to Red, by following the guides below. This will help you to easily produce quality code, identify errors early, and streamline the code review process.
52
48
53
49
### 4.1 Setting up your development environment
@@ -59,6 +55,10 @@ The following requirements must be installed prior to setting up:
59
55
If you're not on Windows, you should also have GNU make installed, and you can optionally install [pyenv](https://github.com/pyenv/pyenv), which can help you run tests for different python versions.
60
56
61
57
1. Fork and clone the repository to a directory on your local machine.
2. Open a command line in that directory and execute the following command:
63
63
```bash
64
64
make newenv
@@ -74,16 +74,20 @@ If you're not on Windows, you should also have GNU make installed, and you can o
74
74
.venv\Scripts\activate
75
75
```
76
76
Each time you open a new command line, you should execute this command first. From here onwards, we will assume you are executing commands from within this activated virtual environment.
77
-
78
-
**Note:** If you're comfortable with setting up virtual environments yourself and would rather do it manually, just run `pip install -Ur tools/dev-requirements.txt` after setting it up.
77
+
4. (optional but recommended) Install pre-commit hook which automatically ensures that you meet our style guide when you make a commit:
78
+
```bash
79
+
pre-commit install
80
+
```
81
+
82
+
**Note:** If you're comfortable with setting up virtual environments yourself and would rather do it manually, just run `pip install -Ur tools/dev-requirements.txt` after setting it up and optionally install a pre-commit hook with `pre-commit install`.
79
83
80
84
### 4.2 Testing
81
85
We're using [tox](https://github.com/tox-dev/tox) to run all of our tests. It's extremely simple to use, and if you followed the previous section correctly, it is already installed to your virtual environment.
82
86
83
87
Currently, tox does the following, creating its own virtual environments for each stage:
84
88
- Runs all of our unit tests with [pytest](https://github.com/pytest-dev/pytest) on python 3.8 (test environment `py38`)
85
89
- Ensures documentation builds without warnings, and all hyperlinks have a valid destination (test environment `docs`)
86
-
- Ensures that the code meets our style guide with [black](https://github.com/psf/black) (test environment `style`)
90
+
- Ensures that the code meets our style guide (test environment `pre-commit`, does not run by default because it changes state of project folder and it is already checked by `pre-commit`)
87
91
88
92
To run all of these tests, just run the command `tox` in the project directory.
89
93
@@ -92,14 +96,97 @@ To run a subset of these tests, use the command `tox -e <env>`, where `<env>` is
92
96
Your PR will not be merged until all of these tests pass.
93
97
94
98
### 4.3 Style
95
-
Our style checker of choice, [black](https://github.com/psf/black), actually happens to be an auto-formatter. The checking functionality simply detects whether or not it would try to reformat something in your code, should you run the formatter on it. For this reason, we recommend using this tool as a formatter, regardless of any disagreements you might have with the style it enforces.
96
-
97
-
Use the command `black --help` to see how to use this tool. The full style guide is explained in detail on [black's GitHub repository](https://github.com/psf/black). **There is one exception to this**, however, which is that we set the line length to 99, instead of black's default 88. This is already set in `pyproject.toml` configuration file in the repo so you can simply format code with Black like so: `black <src>`.
99
+
This project uses a bunch of style checks to ensure that all of the code is formatted consistently.
100
+
We use [pre-commit](https://pre-commit.com/) to ensure that all of these are fulfilled by all PRs made on our repositories.
101
+
102
+
If you've done the optional step of installing a pre-commit hook [4.1 Setting up your development environment](#41-setting-up-your-development-environment) section,
103
+
you actually don't have to worry about anything as all of these style checks are ran automatically whenever you make a commit. However, if you chose not to, you can:
104
+
- run all hooks on currently **staged** (`git add`ed) files with:
105
+
```bash
106
+
pre-commit
107
+
```
108
+
- or run all hooks on all files with:
109
+
```bash
110
+
pre-commit run --all-files
111
+
```
112
+
113
+
Now let's get itnot the specifics of the checks that we have.
114
+
115
+
Primarily, we use [Black](https://github.com/psf/black) and [isort](https://github.com/PyCQA/black) which both are actually auto-formatters.
116
+
This means that the checking functionality simply detects whether or not it would try to reformat something in your code, should you run the formatter on it.
117
+
For this reason, we recommend using these tools as formatters, regardless of any disagreements you might have with the style they enforce.
118
+
119
+
The full style guide is explained in detail in [Black's documentation](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html).
120
+
121
+
**There are two exceptions to this**.
122
+
Firstly, we set the line length to 99, instead of Black's default 88. This is already setin`pyproject.toml` configuration file in the repo so you do not need to specify this when running Black.
123
+
Secondly, we do not allow the usage of `# fmt: skip` and `# fmt: on/off` comments forexcluding parts of code from being reformatted. **All** of the code should be formatted with Blackin full.
124
+
125
+
The other auto-formatter that we use - [isort](https://github.com/PyCQA/black) - only focuses on sorting imports alphabetically, and automatically separated into sections and by type.
126
+
127
+
Imports are sectioned based on where they import from in order:
128
+
- future imports (`from __future__ import ...`)
129
+
- imports from Python's standard library (e.g. `import collections` or `from typing import Any`)
130
+
- imports from third-party libraries (e.g. `import aiohttp` or `from discord.ext import commands`)
131
+
- imports from first-party libraries (imports from `redbot`)
This checks for common misspellings in text files.
182
+
183
+
When necessary, specific lines can be ignored with `.codespell-ignore-lines` file and specific words can be ignored with `.codespell-ignore-words` file.
184
+
Usage of `.codespell-ignore-words` is generally discouraged.
98
185
99
186
### 4.4 Make
100
187
You may have noticed we have a `Makefile` and a `make.bat` in the top-level directory. For now, you can do a few things with them:
101
-
1. `make reformat`: Reformat all python files in the project with Black
102
-
2. `make stylecheck`: Check if any `.py` files in the project need reformatting
188
+
1. `make reformat`: Reformat all python files in the project with Black and isort
189
+
2. `make stylecheck`: Check if any `.py` files in the project need reformatting with Black or isort
103
190
3. `make newenv`: Set up a new virtual environment in the `.venv` subdirectory, and install Red and its dependencies. If one already exists, it is cleared out and replaced.
104
191
4. `make syncenv`: Sync your environment with Red's latest dependencies.
105
192
@@ -115,45 +202,23 @@ Whenever you pull from upstream (V3/develop on the main repository) and you noti
115
202
1. Create a new branch on your fork
116
203
2. Make the changes
117
204
3. If you like the changes and think the main Red project could use it:
118
-
* Run tests with `tox` to ensure your code is up to scratch
205
+
* Run style checks with `pre-commit`.
206
+
* (optional, advised if it's your first non-trivial PR to this project) Run tests with `tox` to ensure your code is up to scratch
119
207
* Create a Pull Request on GitHub with your changes
120
208
- If you are contributing a behavior change, please keep in mind that behavior changes
121
209
are conditional on them being appropriate for the project's current goals.
122
210
If you would like to reduce the risk of putting in effort for something we aren't
123
211
going to use, open an issue discussing it first.
124
212
125
213
### 4.7 How To Report A Bug
126
-
Please see our **ISSUES.MD** for more information.
214
+
After checking that the bug has not already been reported by someone else on our issue tracker, you should create a new issue
215
+
by choosing appropriate type of issue and **carefully** filling out the issue form. Please make sure that you include reproduction steps
216
+
and describe the issue as precisely as you can.
127
217
128
218
### 4.8 How To Suggest A Feature Or Enhancement
129
219
The goal of Red is to be as useful to as many people as possible, this means that all features must be useful to anyone and any server that uses Red.
130
220
131
221
If you find yourself wanting a feature that Red does not already have, you're probably not alone. There's bound to be a great number of users out there needing the same thing and a lot of the features that Red has today have been added because of the needs of our users. Open an issue on our issues list and describe the feature you would like to see, how you would use it, how it should work, and why it would be useful to the Red community as a whole.
132
222
133
-
# 5. Code Review Process
134
-
135
-
We have a core team working tirelessly to implement new features and fix bugs for the Red community. This core team looks at and evaluates new issues and PRs on a daily basis.
136
-
137
-
The decisions we make are based on a simple majority of that team or by decree of the project owner.
138
-
139
-
### 5.1 Issues
140
-
Any new issues will be looked at and evaluated for validity of a bug or for the usefulness of a suggested feature. If we have questions about your issue we will get back as soon as we can (usually in a day or two) and will try to make a decision within a week.
141
-
142
-
### 5.2 Pull Requests
143
-
Pull requests are evaluated by their quality and how effectively they solve their corresponding issue. The process for reviewing pull requests is as follows:
144
-
145
-
1. A pull request is submitted
146
-
2. Core team members will review and test the pull request (usually within a week)
147
-
3. After a member of the core team approves your pull request:
148
-
* If your pull request is considered an improvement or enhancement the project owner will have 1 day to veto or approve your pull request.
149
-
* If your pull request is considered a new feature the project owner will have 1 week to veto or approve your pull request.
150
-
4. If any feedback is given we expect a response within 1 week or we may decide to close the PR.
151
-
5. If your pull request is not vetoed and no core member requests changes then it will be approved and merged into the project.
152
-
153
-
### 5.3 Differences between "new features" and "improvements"
154
-
The difference between a new feature and improvement can be quite fuzzy and the project owner reserves all rights to decide under which category your PR falls.
155
-
156
-
At a very basic level a PR is a new feature if it changes the intended way any part of the Red project currently works or if it modifies the user experience (UX) in any significant way. Otherwise, it is likely to be considered an improvement.
157
-
158
-
# 6. Community
223
+
# 5. Community
159
224
You can chat with the core team and other community members about issues or pull requests in the #coding channel of the Red support server located [here](https://discord.gg/red).
0 commit comments