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
+11-28
Original file line number
Diff line number
Diff line change
@@ -37,13 +37,9 @@ We want your work to be readable by others; therefore, we encourage you to note
37
37
- Expand acronyms because __gcd()__ is hard to understand but __greatest_common_divisor()__ is not.
38
38
- Please follow the [Python Naming Conventions](https://pep8.org/#prescriptive-naming-conventions) so variable_names and function_names should be lower_case, CONSTANTS in UPPERCASE, ClassNames should be CamelCase, etc.
39
39
40
-
41
-
42
40
- We encourage the use of Python [f-strings](https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python) where the make the code easier to read.
43
41
44
-
45
-
46
-
- Please consider running [__psf/black__](https://github.com/python/black) on your Python file(s) before submitting your pull request. This is not yet a requirement but it does make your code more readable and automatically aligns it with much of [PEP 8](https://www.python.org/dev/peps/pep-0008/). There are other code formatters (autopep8, yapf) but the __black__ style is now the recommendation of the Python Core Team. To use it,
42
+
- Please consider running [__psf/black__](https://github.com/python/black) on your Python file(s) before submitting your pull request. This is not yet a requirement but it does make your code more readable and automatically aligns it with much of [PEP 8](https://www.python.org/dev/peps/pep-0008/). There are other code formatters (autopep8, yapf) but the __black__ formatter is now hosted by the Python Software Foundation. To use it,
47
43
48
44
```bash
49
45
pip3 install black # only required the first time
@@ -57,13 +53,11 @@ We want your work to be readable by others; therefore, we encourage you to note
- Original code submission require docstrings or comments to describe your work.
63
57
64
58
- More on docstrings and comments:
65
59
66
-
If you are using a Wikipedia article or some other source material to create your algorithm, please add the URL in a docstring or comment to help your reader.
60
+
If you used a Wikipedia article or some other source material to create your algorithm, please add the URL in a docstring or comment to help your reader.
67
61
68
62
The following are considered to be bad and may be requested to be improved:
69
63
@@ -73,29 +67,27 @@ We want your work to be readable by others; therefore, we encourage you to note
73
67
74
68
This is too trivial. Comments are expected to be explanatory. For comments, you can write them above, on or below a line of code, as long as you are consistent within the same piece of code.
75
69
76
-
We encourage you to put docstrings inside your functions but please pay attention to indentation of docstrings. The following is acceptable in this case:
70
+
We encourage you to put docstrings inside your functions but please pay attention to indentation of docstrings. The following is a good example:
77
71
78
72
```python
79
-
defsumab(a, b):
73
+
defsum_ab(a, b):
80
74
"""
81
-
This function returns the sum of two integers a and b
82
-
Return: a + b
75
+
Return the sum of two integers a and b.
83
76
"""
84
77
return a + b
85
78
```
86
79
87
80
- Write tests (especially [__doctests__](https://docs.python.org/3/library/doctest.html)) to illustrate and verify your work. We highly encourage the use of _doctests on all functions_.
88
81
89
82
```python
90
-
defsumab(a, b):
83
+
defsum_ab(a, b):
91
84
"""
92
-
This function returns the sum of two integers a and b
93
-
Return: a + b
94
-
>>> sumab(2, 2)
85
+
Returns the sum of two integers a and b
86
+
>>> sum_ab(2, 2)
95
87
4
96
-
>>> sumab(-2, 3)
88
+
>>> sum_ab(-2, 3)
97
89
1
98
-
>>> sumab(4.9, 5.1)
90
+
>>> sum_ab(4.9, 5.1)
99
91
10.0
100
92
"""
101
93
return a + b
@@ -125,15 +117,11 @@ We want your work to be readable by others; therefore, we encourage you to note
125
117
126
118
```python
127
119
defsumab(a: int, b: int) --> int:
128
-
pass
120
+
pass
129
121
```
130
122
131
-
132
-
133
123
-[__List comprehensions and generators__](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions) are preferred over the use of `lambda`, `map`, `filter`, `reduce` but the important thing is to demonstrate the power of Python in code that is easy to read and maintain.
134
124
135
-
136
-
137
125
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
138
126
- If you need a third party module that is not in the file __requirements.txt__, please add it to that file as part of your submission.
139
127
@@ -143,17 +131,12 @@ We want your work to be readable by others; therefore, we encourage you to note
143
131
- Strictly use snake_case (underscore_separated) in your file_name, as it will be easy to parse in future using scripts.
144
132
- Please avoid creating new directories if at all possible. Try to fit your work into the existing directory structure.
145
133
- If possible, follow the standard *within* the folder you are submitting to.
146
-
147
-
148
-
149
134
- If you have modified/added code work, make sure the code compiles before submitting.
150
135
- If you have modified/added documentation work, ensure your language is concise and contains no grammar errors.
151
136
- Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our Travis CI processes.
152
137
- Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended).
153
138
- 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.
154
139
155
-
156
-
157
140
- Most importantly,
158
141
-**Be consistent in the use of these guidelines when submitting.**
0 commit comments