|
6 | 6 | <https://github.com/PyThaiNLP/pythainlp/blob/dev/tests/README.md>. |
7 | 7 | The document list test categories, their dependency sets, |
8 | 8 | and test naming conventions. |
| 9 | +- [ ] Use reStructuredText for docstring (PEP 287), targetting Sphinx. |
| 10 | +- [ ] When possible, follow NLTK established convention of submodule |
| 11 | + name (tend to be a verb or a generic noun), function name, and |
| 12 | + configuration. Communicate this to the users during code review. |
| 13 | + See <https://www.nltk.org/py-modindex.html>. |
9 | 14 |
|
10 | 15 | ## Project contribution guidelines |
11 | 16 |
|
|
185 | 190 | file I/O, network I/O, etc. |
186 | 191 | - [ ] Use type hints for function/method signatures |
187 | 192 | and variable declarations as much as possible. |
| 193 | + - [ ] Follow best practices and standard Python type hint patterns. |
| 194 | + - [ ] Use mypy as an assistant. |
| 195 | + - [ ] mypy is in "dev" optional dependency. |
| 196 | + - [ ] Sometimes mypy may report errors wrongly due to cache issues. |
| 197 | + Try to reset the cache if unexpected errors occured. |
| 198 | + - [ ] Use pyright, pyrefly, and pytype for second opinions. |
| 199 | + - [ ] When insert typing imports, put it in appropriate location and order. |
| 200 | + Use "if TYPE_CHECKING import" block when possible. |
| 201 | + - [ ] Try to find type information for external libraries: |
| 202 | + - [ ] Check if type stub is available and install it. |
| 203 | + - [ ] Check if source code is available and analyze it for correct types. |
| 204 | + - [ ] Recheck necessity of casting. |
| 205 | + - [ ] Recheck necessity of `# noqa:` and `# type: ignore`. |
| 206 | + - [ ] Recheck docstring and documentation consistency with the code; |
| 207 | + They should match the updated type hints. |
188 | 208 | - [ ] requires-python in pyproject.toml should reflect the minimum |
189 | 209 | Python version supported by the project. |
190 | 210 | - [ ] Do not introduce syntax or features that are not supported |
|
196 | 216 | runtime type inspection tools, documentation generators, and static |
197 | 217 | analysis tools. |
198 | 218 | For example, typing.get_type_hints() should work properly. |
| 219 | +- [ ] Do not allow the use of assert in production code |
| 220 | + (it is only allowed for testing and debugging). |
199 | 221 | - [ ] Do not use mutable default arguments in function/method definitions. |
200 | 222 | - [ ] Do not use wildcard imports (from module import *). |
| 223 | +- [ ] When reordering the imports, be careful not to (re-)introduce circular |
| 224 | + import. Read comments near imports to get more information. |
| 225 | +- [ ] Remove unused imports. |
201 | 226 | - [ ] Remove any trailing whitespace in the Python file. |
202 | 227 | - [ ] Make the package zip-safe if possible. |
203 | 228 | - [ ] Be mindful about choice of data structures. |
|
208 | 233 | `collections.abc` modules. |
209 | 234 | Use the most appropriate data structure for the specific use case |
210 | 235 | to optimize performance and memory usage. |
| 236 | +- [ ] Recheck formatting with Ruff. |
211 | 237 |
|
212 | 238 | ## JSON |
213 | 239 |
|
|
0 commit comments