From b2b5c2f6416b972797f6801a57f92c691fba7504 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 28 Oct 2022 00:12:00 +0300 Subject: [PATCH 1/3] Update developer toolset instructions in CONTRIBUTING.md --- CONTRIBUTING.md | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5a07af100ee..b589a3ac125e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,19 +74,12 @@ We want your work to be readable by others; therefore, we encourage you to note - 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 they make the code easier to read. -- 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, - - ```bash - python3 -m pip install black # only required the first time - black . - ``` - -- All submissions will need to pass the test `flake8 . --ignore=E203,W503 --max-line-length=88` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request. - - ```bash - python3 -m pip install flake8 # only required the first time - flake8 . --ignore=E203,W503 --max-line-length=88 --show-source - ``` +- Do not forget that running `pre-commit` checks locally will help you to follow code quality standards. + It will run a set of tools including + [black](https://github.com/psf/black), + [isort](https://github.com/PyCQA/isort), + [mypy](http://mypy-lang.org) and + [flake8](https://flake8.pycqa.org/en/latest/). - Original code submission require docstrings or comments to describe your work. @@ -148,15 +141,14 @@ We want your work to be readable by others; therefore, we encourage you to note starting_value = int(input("Please enter a starting value: ").strip()) ``` - The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally before making your submission. + The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. + Our automated testing will run [mypy](http://mypy-lang.org) so run that locally with pre-commit before making your submission. ```python def sum_ab(a: int, b: int) -> int: return a + b ``` - Instructions on how to install mypy can be found [here](https://github.com/python/mypy). Please use the command `mypy --ignore-missing-imports .` to test all files or `mypy --ignore-missing-imports path/to/file.py` to test a specific file. - - [__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. - Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms. @@ -172,7 +164,6 @@ 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. - Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our GitHub Actions processes. - 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 you to add [__Python type hints__](https://docs.python.org/3/library/typing.html) where it makes sense to do so. - Most importantly, - __Be consistent in the use of these guidelines when submitting.__ From 1e074278b940ee7588af3653aeb25ed373c41800 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 6 Nov 2022 01:22:27 +0300 Subject: [PATCH 2/3] Update CONTRIBUTING.md --- CONTRIBUTING.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f277c9d553c..d72d15a5f925 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,7 +56,14 @@ Use [pre-commit](https://pre-commit.com/#installation) to automatically format y python3 -m pip install pre-commit # only required the first time pre-commit install ``` -That's it! The plugin will run every time you commit any changes. If there are any errors found during the run, fix them and commit those changes. You can even run the plugin manually on all files: +That's it! The plugin will run every time you commit any changes. If there are any errors found during the run, fix them and commit those changes. +Pre-commit includes +[black](https://github.com/psf/black), +[isort](https://github.com/PyCQA/isort), +[mypy](http://mypy-lang.org) and +[flake8](https://flake8.pycqa.org/en/latest/). + +You can even run the plugin manually on all files: ```bash pre-commit run --all-files --show-diff-on-failure @@ -74,13 +81,6 @@ We want your work to be readable by others; therefore, we encourage you to note - 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 they make the code easier to read. -- Do not forget that running `pre-commit` checks locally will help you to follow code quality standards. - It will run a set of tools including - [black](https://github.com/psf/black), - [isort](https://github.com/PyCQA/isort), - [mypy](http://mypy-lang.org) and - [flake8](https://flake8.pycqa.org/en/latest/). - - Original code submission require docstrings or comments to describe your work. - More on docstrings and comments: @@ -141,7 +141,7 @@ We want your work to be readable by others; therefore, we encourage you to note starting_value = int(input("Please enter a starting value: ").strip()) ``` - The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. + The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally with pre-commit before making your submission. ```python From 474bc03d25b249d9d1cd77d30922a2d7c050c008 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 17 Mar 2023 19:08:06 +0100 Subject: [PATCH 3/3] Add ruff to list of tools --- CONTRIBUTING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a52cae3e1d93..20934b456aff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,9 +59,8 @@ pre-commit install That's it! The plugin will run every time you commit any changes. If there are any errors found during the run, fix them and commit those changes. Pre-commit includes [black](https://github.com/psf/black), -[isort](https://github.com/PyCQA/isort), -[mypy](http://mypy-lang.org) and -[flake8](https://flake8.pycqa.org/en/latest/). +[ruff](https://beta.ruff.rs/docs/) +[mypy](http://mypy-lang.org). You can even run the plugin manually on all files: