diff --git a/.gitea/workflows/python-package.yml b/.gitea/workflows/python-package.yml index 09275ea..2ee342a 100644 --- a/.gitea/workflows/python-package.yml +++ b/.gitea/workflows/python-package.yml @@ -3,7 +3,7 @@ on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' - paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"] + paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] jobs: Package: diff --git a/.gitea/workflows/python-test.yml b/.gitea/workflows/python-test.yml index 91cab99..b51db74 100644 --- a/.gitea/workflows/python-test.yml +++ b/.gitea/workflows/python-test.yml @@ -2,7 +2,7 @@ name: Run Python tests (through Pytest) on: push: - paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"] + paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] jobs: Test: diff --git a/.gitea/workflows/python-version-check.yml b/.gitea/workflows/python-version-check.yml index dba12e5..3c9b44d 100644 --- a/.gitea/workflows/python-version-check.yml +++ b/.gitea/workflows/python-version-check.yml @@ -2,7 +2,7 @@ name: Verify Python project can be installed, loaded and have version checked on: push: - paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"] + paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] jobs: Test: diff --git a/CONVENTIONS.md b/CONVENTIONS.md new file mode 100644 index 0000000..7fc9a32 --- /dev/null +++ b/CONVENTIONS.md @@ -0,0 +1,32 @@ +# Conventions + +When contributing code to this project, you MUST follow the requirements +specified here. + +## Code Conventions + +When contributing code to this project, you MUST follow these principles: + +- Code should be easy to read and understand. +- Keep the code as simple as possible. Avoid unnecessary complexity. +- Use meaningful names for variables, functions, etc. Names should reveal intent. +- Functions should be small and do one thing well. They should not exceed a few lines. +- Function names should describe the action being performed. +- Only use comments when necessary, as they can become outdated. Instead, strive to make the code self-explanatory. +- When comments are used, they should add useful information that is not readily apparent from the code itself. +- Properly handle errors and exceptions to ensure the software's robustness. +- Use exceptions rather than error codes for handling errors. +- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks. +- Documentation should document semantics, not syntax. +- Prefer importing modules, not individual items from modules. +- Do not use f-strings in logging statements. +- Loop variables and walrus-expression-variables should be deleted when + unneeded to keep scope clean, and to avoid accidental use. + +## Testing + +When contributing test to this project, you MUST follow these principles: + +- Do not use any testing libraries other than `pytest`. +- Mocking is the root of all evil. Writing your own stubs is much more + preferable. diff --git a/README.md b/README.md index b1ecb84..f59eda2 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,28 @@ This project requires [Python](https://www.python.org/) 3.8 or newer. This project does not have any library requirements 😎 +## Contributing + +Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so. + + +### Testing + +Testing requires the [pytest](https://docs.pytest.org/en/stable/) library. + +Run tests with the following command: + +```sh +pytest test +``` + +Test coverage can be run using the [`pytest-cov`](https://pypi.org/project/pytest-cov/) extension: + +```sh +pytest --cov=standardize_test_format test +``` + + ## License ```