Thank you for your interest in contributing to F2
! 🎉 Whether it's fixing bugs, adding new features, or improving documentation, we welcome your contributions. Before you start, we recommend opening an issue or emailing [email protected]
to discuss it. Please take a moment to read through this guide to understand our development process.
Important
You will need to install Python
, and we strongly recommend using a virtual environment to manage dependencies.
The remainder of this guide assumes you are working within a virtual environment.
To get started with the project, follow the Installation guide in the official documentation.
Next, follow the steps for PR Contributors.
When developing for F2
, keep the following points in mind:
- Avoid Variable Name Abbreviations: Descriptive variable names make the code more readable and easier to maintain.
- Consistency is Key: Follow the established coding style throughout the project.
- Documentation is Important: Ensure your code is well-documented, especially new features or complex logic.
- Avoid Hardcoding: Do not hardcode sensitive information; store configuration details in the
conf.yaml
file.
Before committing your code, ensure you:
- Run Tests: Make sure all tests pass.
- Check for Type Errors: Use type checking tools to catch any type issues.
- Format Code: Use
black
to auto-format your code according toPEP 8
style guidelines.
F2
uses black
for code formatting. It is recommended to set up black
in your editor to format your code on save.
If you are using VSCode
, the black
formatter is already configured. Alternatively, you can format the code manually by running the following command from the project root:
$ black **/*.py --exclude venv/*
F2
uses pytest
for unit testing. Here are the steps to run tests:
- Set up the Test Environment: Ensure the test configuration is prepared. For asynchronous code, use the
pytest-asyncio
plugin. - Write Tests: Always add tests for new features or bug fixes.
- Mock External Dependencies: Use
unittest.mock
to mock external dependencies. - Check Test Coverage: Review test coverage to ensure nothing is missed.
To run tests from the project root, use the following commands:
Normal tests:
$ pytest -vv
Coverage tests:
$ pytest --cov-report term-missing --cov=f2 ./ -vv
Ideally, new code should be covered by tests and should not break existing tests. If modified or newly added code does not appear in the coverage report, it is strongly advised to add relevant tests.
Important
If you have the F2
localization tool Babel
installed, you do not need to install gettext
separately.
To add translations:
- Run the following script from the project root to generate
.pot
and.po
files:
(Windows)
$ make_pot.bat
(Linux/macOS)
$ make_pot.sh
- Translate the
.po
files to the desired language. We recommend using the Poedit tool. - Compile the
.po
files into.mo
files and place them in the respective language folder underlanguages
.
Consider whether the changes you make require documentation updates. If so, you should add documentation.
Building the documentation requires additional dependencies. You can install them by running the following commands from the docs
directory:
- Run Documentation Locally:
Use
pnpm
to runVitePress
:
$ cd docs
$ pnpm i
$ pnpm docs:dev
- Write Documentation: Add new code-related documentation in the
docs
directory. Follow the existing style and format. - Build Documentation Locally: Before submitting your code, ensure the documentation builds correctly. Generate static documentation:
$ pnpm docs:build
If this is your first contribution to F2
, welcome! 🎉
You need to update the following files:
- ChangeLog: Update the summary of your changes in the
CHANGELOG.md
file. - Contributors: Add your name to the
CONTRIBUTORS.md
file. - Team: Add your information to the
team.md
file in the documentation.
Once you are satisfied with your code and have followed all the above steps, and your code passes all tests, you can create a Pull Request
for your forked
branch.
GitHub
provides a useful guide to help you create a PR
. Be sure to include a description of your changes and link to the related Issue
or discussion.
All code changes are subject to a code review. Wait for the repository's code review bot to automatically check your code. There may be some discussions and iterations. In most cases, a few iterations are needed to fully address any issues.
Once your PR
is approved, it will be merged into the main
branch and made available to all users in the next release. 🚀