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
docs: fix outdated references in CONTRIBUTING.md (#15188)
* docs: fix outdated references in CONTRIBUTING.md
- Update Python version from 3.13+ to 3.14+ (matches pyproject.toml)
- Replace outdated black formatter recommendation with ruff format (matches .pre-commit-config.yaml)
- Update PEP 8 URL to canonical peps.python.org (old URL 302-redirects)
- Fix inconsistent mypy URL from http://www.mypy-lang.org to https://mypy-lang.org
* docs: point CONTRIBUTING.md at the tooling CI actually runs
- `ruff .` -> `ruff check .`: bare `ruff .` fails with "unrecognized
subcommand '.'"; .github/workflows/ruff.yml runs `ruff check ... .`
- mypy -> ty: the mirrors-mypy pre-commit hook is commented out and no
workflow runs mypy, while .github/workflows/ty.yml runs `ty check` on
every pull request
- requirements.txt -> pyproject.toml: requirements.txt was deleted in
#13486 ("dependencies are in pyproject.toml")
* docs: note that the ty check is informational
Addresses Copilot review feedback: .github/workflows/ty.yml sets
`continue-on-error: true` and passes `--exit-zero` ("ty is not yet a
required gate"), so the previous wording implied an enforced gate.
* Apply batched suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix grammar and punctuation in CONTRIBUTING.md
Correct grammar and punctuation throughout the document for clarity and consistency.
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+26-21Lines changed: 26 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ __Improving comments__ and __writing proper tests__ are also highly welcome.
23
23
24
24
We appreciate any contribution, from fixing a grammar mistake in a comment to implementing complex algorithms. Please read this section if you are contributing your work.
25
25
26
-
Your contribution will be tested by our [automated testing on GitHub Actions](https://github.com/TheAlgorithms/Python/actions) to save time and mental energy. After you have submitted your pull request, you should see the GitHub Actions tests start to run at the bottom of your submission page. If those tests fail, then click on the ___details___ button to read through the GitHub Actions output to understand the failure. If you do not understand, please leave a comment on your submission page and a community member will try to help.
26
+
Your contribution will be tested by our [automated testing on GitHub Actions](https://github.com/TheAlgorithms/Python/actions) to save time and mental energy. After you have submitted your pull request, you should see the GitHub Actions tests start to run at the bottom of your submission page. If those tests fail, then click on the ___details___ button to read through the GitHub Actions output to understand the failure. If you do not understand, please leave a comment on your submission page, and a community member will try to help.
27
27
28
28
#### Issues
29
29
@@ -46,7 +46,7 @@ An Algorithm is one or more functions (or classes) that:
46
46
* return one or more outputs,
47
47
* have minimal side effects (Ex. `print()`, `plot()`, `read()`, `write()`).
48
48
49
-
Algorithms should be packaged in a way that would make it easy for readers to put them into larger programs.
49
+
Algorithms should be packaged in a way that makes it easy for readers to put them into larger programs.
50
50
51
51
Algorithms should:
52
52
* have intuitive class and function names that make their purpose clear to readers
@@ -58,7 +58,7 @@ Algorithms should:
58
58
* contain doctests that test both valid and erroneous input values
59
59
* return all calculation results instead of printing or plotting them
60
60
61
-
Algorithms in this repo should not be how-to examples for existing Python packages. Instead, they should perform internal calculations or manipulations to convert input values into different output values. Those calculations or manipulations can use data types, classes, or functions of existing Python packages but each algorithm in this repo should add unique value.
61
+
Algorithms in this repo should not be how-to examples for existing Python packages. Instead, they should perform internal calculations or manipulations to convert input values into different output values. Those calculations or manipulations can use data types, classes, or functions of existing Python packages, but each algorithm in this repo should add unique value.
62
62
63
63
#### Pre-commit plugin
64
64
Use [pre-commit](https://pre-commit.com/#installation) to automatically format your code to match our coding style:
@@ -67,7 +67,7 @@ Use [pre-commit](https://pre-commit.com/#installation) to automatically format y
67
67
python3 -m pip install pre-commit # only required the first time
68
68
pre-commit install
69
69
```
70
-
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:
70
+
That's it! The plugin will run every time you commit any changes. If any errors are found during the run, fix them and commit those changes. You can even run the plugin manually on all files:
71
71
72
72
```bash
73
73
pre-commit run --all-files --show-diff-on-failure
@@ -77,22 +77,22 @@ pre-commit run --all-files --show-diff-on-failure
77
77
78
78
We want your work to be readable by others; therefore, we encourage you to note the following:
79
79
80
-
- Please write in Python 3.13+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
80
+
- Please write in free-threaded Python 3.14t+. For instance: `print()` is a function in Python 3, so `print "Hello"` will *not* work, but `print("Hello")` will.
81
81
- Please focus hard on the naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
82
-
- Singleletter variable names are *old school* so please avoid them unless their life only spans a few lines.
82
+
- Single-letter variable names are *old school*, so please avoid them unless their life only spans a few lines.
83
83
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.
84
84
- 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.
85
85
86
86
- 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.
87
87
88
-
- 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,
88
+
- Please consider running [__ruff format__](https://docs.astral.sh/ruff/formatter/) 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://peps.python.org/pep-0008/). To use it,
89
89
90
90
```bash
91
-
python3 -m pip install black# only required the first time
92
-
black .
91
+
python3 -m pip install ruff# only required the first time
92
+
ruff format
93
93
```
94
94
95
-
- All submissions will need to pass the test `ruff .` before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
95
+
- All submissions will need to pass the test `ruff check` before they will be accepted, so if possible, try this test locally on your Python file(s) before submitting your pull request.
96
96
97
97
```bash
98
98
python3 -m pip install ruff # only required the first time
@@ -103,17 +103,17 @@ We want your work to be readable by others; therefore, we encourage you to note
103
103
104
104
- More on docstrings and comments:
105
105
106
-
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.
106
+
If you used a Wikipedia article or other source material to create your algorithm, please add the URL in a docstring or comment to help your reader.
107
107
108
108
The following are considered to be bad and may be requested to be improved:
109
109
110
110
```python
111
111
x = x +2# increased by 2
112
112
```
113
113
114
-
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.
114
+
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.
115
115
116
-
We encourage you to put docstrings inside your functions but please pay attention to the indentation of docstrings. The following is a good example:
116
+
We encourage you to put docstrings inside your functions, but please pay attention to the indentation of docstrings. The following is a good example:
117
117
118
118
```python
119
119
defsum_ab(a, b):
@@ -139,7 +139,7 @@ We want your work to be readable by others; therefore, we encourage you to note
139
139
return a + b
140
140
```
141
141
142
-
These doctests will be run by pytest as part of our automated testing so please try to run your doctests locally and make sure that they are found and pass:
142
+
These doctests will be run by pytest as part of our automated testing, so please try to run your doctests locally and make sure that they are found and pass:
143
143
144
144
```bash
145
145
python3 -m doctest -v my_submission.py
@@ -159,31 +159,36 @@ We want your work to be readable by others; therefore, we encourage you to note
159
159
starting_value =int(input("Please enter a starting value: ").strip())
160
160
```
161
161
162
-
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](https://mypy-lang.org) so run that locally before making your submission.
162
+
The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our CI runs [ty](https://docs.astral.sh/ty/) as an informational check that does not block merges yet, so you may want to run it locally before making your submission.
163
+
164
+
```bash
165
+
python3 -m pip install ty # only required the first time
166
+
ty check my_file_path.py
167
+
```
163
168
164
169
```python
165
170
defsum_ab(a: int, b: int) -> int:
166
171
return a + b
167
172
```
168
173
169
-
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.
174
+
Instructions on how to install ty can be found [here](https://docs.astral.sh/ty/installation/). Please use the command `ty check` to test all files or `ty check path/to/file.py` to test a specific file.
170
175
171
176
-[__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.
172
177
173
178
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
174
-
- 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.
179
+
- If you need a third-party module that is not already listed in __pyproject.toml__, please add it to the `dependencies` there as part of your submission. The `uv-lock` pre-commit hook will update `uv.lock` to match.
175
180
176
181
#### Other Requirements for Submissions
177
182
- If you are submitting code in the `project_euler/` directory, please also read [the dedicated Guideline](https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md) before contributing to our Project Euler library.
178
183
- The file extension for code files should be `.py`. Jupyter Notebooks should be submitted to [TheAlgorithms/Jupyter](https://github.com/TheAlgorithms/Jupyter).
179
-
- Strictly use snake_case (underscore_separated) in your file_name, as it will be easy to parse in future using scripts.
184
+
- Strictly use snake_case (underscore_separated) in your file_name, as it will be easy to parse in the future using scripts.
180
185
- Please avoid creating new directories if at all possible. Try to fit your work into the existing directory structure.
181
186
- If possible, follow the standard *within* the folder you are submitting to.
182
-
- If you have modified/added code work, make sure the code compiles before submitting.
187
+
- If you have modified/added code, make sure the code compiles before submitting.
183
188
- If you have modified/added documentation work, ensure your language is concise and contains no grammar errors.
184
-
- Do not update the README.md or DIRECTORY.md file which will be periodically autogenerated by our GitHub Actions processes.
189
+
- Do not update the README.md or DIRECTORY.md file, which will be periodically autogenerated by our GitHub Actions processes.
185
190
- Add a corresponding explanation to [Algorithms-Explanation](https://github.com/TheAlgorithms/Algorithms-Explanation) (Optional but recommended).
186
-
-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.
191
+
-Our CI runs [__ty__](https://docs.astral.sh/ty/) on every pull request as an informational check that does not block merges yet, so we encourage you to add [__Python type hints__](https://docs.python.org/3/library/typing.html) where `ty` recommends to do so.
187
192
188
193
- Most importantly,
189
194
-__Be consistent in the use of these guidelines when submitting.__
0 commit comments