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
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+29-14Lines changed: 29 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,10 @@ Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Befo
10
10
11
11
We are very happy that you consider implementing algorithms and data structure for others! This repository is referenced and used by learners from all over the globe. Being one of our contributors, you agree and confirm that:
12
12
13
-
-your did your work - no plagiarism allowed
13
+
-You did your work - no plagiarism allowed
14
14
- Any plagiarized work will not be merged.
15
-
-your work will be distributed under [MIT License](License) once your pull request is merged
16
-
-you submitted work fulfils or mostly fulfils our styles and standards
15
+
-Your work will be distributed under [MIT License](License) once your pull request is merged
16
+
-You submitted work fulfils or mostly fulfils our styles and standards
17
17
18
18
**New implementation** is welcome! For example, new solutions for a problem, different representations for a graph data structure or algorithm designs with different complexity.
19
19
@@ -28,6 +28,13 @@ We appreciate any contribution, from fixing a grammar mistake in a comment to im
28
28
We want your work to be readable by others; therefore, we encourage you to note the following:
29
29
30
30
- Please write in Python 3.x.
31
+
- Please consider running [__python/black__](https://github.com/python/black) on your Python file(s) before submitting your pull request. This is not a requirement but it does make your code more readable. There are other code formatters (autopep8, yapf) but the __black__ style is now the recommendation of the Python core team. To use it,
32
+
```bash
33
+
pip3 install black # only required the first time
34
+
black my-submission.py
35
+
```
36
+
37
+
- All submissions will need to pass the test __flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics__ before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
31
38
32
39
- If you know [PEP 8](https://www.python.org/dev/peps/pep-0008/) already, you will have no problem in coding style, though we do not follow it strictly. Read the remaining section and have fun coding!
33
40
@@ -72,13 +79,19 @@ We want your work to be readable by others; therefore, we encourage you to note
72
79
73
80
- Write tests to illustrate your work.
74
81
75
-
The following "testing" approaches are not encouraged:
82
+
The following "testing" approaches are **not** encouraged:
76
83
77
84
```python
78
85
input('Enter your input:')
79
86
# Or even worse...
80
87
input = eval(raw_input("Enter your input: "))
81
88
```
89
+
90
+
However, if your code uses __input()__ then we encourage you to gracefully deal with leading and trailing whitespace in user input by adding __.strip()__ to the end as in:
91
+
92
+
```python
93
+
starting_value = int(input("Please enter a starting value: ").strip())
94
+
```
82
95
83
96
Please write down your test case, like the following:
84
97
@@ -92,31 +105,33 @@ We want your work to be readable by others; therefore, we encourage you to note
92
105
print("1 + 2 = ", sumab(1,2)) # 1+2 = 3
93
106
print("6 + 4 = ", sumab(6,4)) # 6+4 = 10
94
107
```
108
+
109
+
Better yet, if you know how to write [__doctests__](https://docs.python.org/3/library/doctest.html), please consider adding them.
95
110
96
-
- Avoid importing external libraries for basic algorithms. Use those libraries for complicated algorithms.
111
+
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
97
112
98
113
#### Other Standard While Submitting Your Work
99
114
100
-
- File extension for code should be `.py`.
115
+
- File extension forcode should be `.py`. Jupiter notebook files are acceptablein machine learning algorithms.
101
116
102
-
- Please file your work to let others use it in the future. Here are the examples that are acceptable:
103
-
104
-
- Camel cases
105
-
-`-` Hyphenated names
106
-
-`_` Underscore-separated names
117
+
- Strictly use snake case (underscore separated) in your file name, as it will be easy to parse in future using scripts.
107
118
108
119
If possible, follow the standard *within* the folder you are submitting to.
109
120
110
121
- If you have modified/added code work, make sure the code compiles before submitting.
111
122
112
-
- If you have modified/added documentation work, make sure your language is concise and contains no grammar mistake.
123
+
- If you have modified/added documentation work, ensure your language is concise and contains no grammar errors.
124
+
125
+
- Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our Travis CI processes.
113
126
114
127
- Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended).
115
128
129
+
- All submissions will be tested with [__mypy__](http://www.mypy-lang.org) so we encourage to add [__Python type hints__](https://docs.python.org/3/library/typing.html) where it makes sense to do so.
130
+
116
131
- Most importantly,
117
132
118
-
-**be consistent with this guidelines while submitting.**
0 commit comments