From 86e2afa578631a095b76724c765cadbf50c334ce Mon Sep 17 00:00:00 2001 From: cclauss Date: Sun, 7 Jul 2019 11:00:31 +0200 Subject: [PATCH 1/3] Update CONTRIBUTING.md to match #964 Blocked by #964 --- CONTRIBUTING.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 03de387a8acd..1c2fc111da99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,13 @@ We appreciate any contribution, from fixing a grammar mistake in a comment to im We want your work to be readable by others; therefore, we encourage you to note the following: - Please write in Python 3.x. +- 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. + ```bash + pip3 install black # only required the first time + black my-submission.py + ``` + +- 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. - 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! @@ -74,11 +81,17 @@ We want your work to be readable by others; therefore, we encourage you to note The following "testing" approaches are **not** encouraged: - ```python* + ```python input('Enter your input:') # Or even worse... input = eval(raw_input("Enter your input: ")) ``` + + 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: + + ```python + starting_value = int(input("Please enter a starting value: ").strip()) + ``` Please write down your test case, like the following: @@ -92,8 +105,10 @@ We want your work to be readable by others; therefore, we encourage you to note print("1 + 2 = ", sumab(1,2)) # 1+2 = 3 print("6 + 4 = ", sumab(6,4)) # 6+4 = 10 ``` + + Better yet, if you know how to write [__doctests__](https://docs.python.org/3/library/doctest.html), please consider adding them. -- Avoid importing external libraries for basic algorithms. Use those libraries for complicated algorithms. +- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms. #### Other Standard While Submitting Your Work @@ -105,15 +120,17 @@ We want your work to be readable by others; therefore, we encourage you to note - If you have modified/added code work, make sure the code compiles before submitting. -- If you have modified/added documentation work, make sure your language is concise and contains no grammar mistake. +- If you have modified/added documentation work, ensure your language is concise and contains no grammar errors. - Update the README file if you have added any new algorithm. Only entry corresponding to the algorithm is to be made, not need to add sample data, test files or solutions to problems like Project Euler, in the README. - Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended). +- 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. + - Most importantly, - - **Be consistent with this guidelines while submitting.** + - **Be consistent in the use of these guidelines when submitting.** - **Join** [Gitter](https://gitter.im/TheAlgorithms) **now!** - Happy coding! From a14f1c0f071241bfb2bff70e0f84a024efef16a3 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sun, 7 Jul 2019 18:45:40 +0200 Subject: [PATCH 2/3] Do not modify README or DIRECTORY file. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c2fc111da99..f1b2e9f16cee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,7 +122,7 @@ We want your work to be readable by others; therefore, we encourage you to note - If you have modified/added documentation work, ensure your language is concise and contains no grammar errors. -- Update the README file if you have added any new algorithm. Only entry corresponding to the algorithm is to be made, not need to add sample data, test files or solutions to problems like Project Euler, in the README. +- Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our Travis CI processes. - Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended). From edc6ee502cddd620de7acba3aa85608936733809 Mon Sep 17 00:00:00 2001 From: John Law Date: Mon, 8 Jul 2019 23:32:53 +0800 Subject: [PATCH 3/3] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1b2e9f16cee..02235ee89973 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,7 +28,7 @@ We appreciate any contribution, from fixing a grammar mistake in a comment to im We want your work to be readable by others; therefore, we encourage you to note the following: - Please write in Python 3.x. -- 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. +- 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, ```bash pip3 install black # only required the first time black my-submission.py