- Lint:
make lint. - Test:
make test.
- Don't modify the
_wirio_settings.pyifile manually. It's generated automatically bymaturin. If you need to modify it, do so in thelib.rsfile and then runmake generate-stubsto regenerate the.pyifile. - Review the added code and write comprehensive unit tests to achieve 100% test coverage. Use
cargo llvm-cov --textto check the coverage. - Don't stop until the next steps, in order, pass: linter and tests.
- After all steps, review if the documentation needs to be updated. If it does, update it accordingly.
- When
expectis used, provide a message that describes the reason for the expectation. It must start with a capital letter and not end with a period. - Don't modify the
_wirio_settings.pyifile manually. It is generated automatically bymaturin. If you need to modify it, do so in thelib.rsfile and then runmake generate-stubsto regenerate the.pyifile. - When using PyO3, use attributes instead of functions such as
.add_functionoradd_submodule.
- Test names must start with
test_, be followed by a verb in present tense, and read asThe test should.... The names mustn't include the word "should", and they must be descriptive and concise, avoiding the inclusion of the tested function whenever possible. Examples:test_create_user,test_fail_when_creating_user_with_untrusted_email,test_ban_user_using_administrator_account. - Append new test cases to the end of the existing ones.
- Use
unwrapinstead ofexpectin tests. - Instead of creating structs for testing, use the
mockallcrate for mocking. - Mock variables must end with
_mock. For example,configuration_mock. - To create temporary files in tests, use the
tempfilecrate. - Asynchronous tests must be annotated using
#[tokio::test]instead of#[test].
- Package manager:
uv.
- Use type hints everywhere.
- Use standard decorators, such as
@overrideor@abstractmethod, when appropriate. - Use
@finalfor classes that are not meant to be inherited from, and for methods that are not meant to be overridden (if the class is not already marked as final). - Don't create standalone functions outside the class for class-specific logic.
- Don't create aliases.
- When adding private methods (those starting with an underscore), add them at the end of the class, after all public methods.
- Do not rely on Python truthiness in conditionals. Agents mustn't generate
if value:orif not value:, except when checking booleans. - Use explicit comparisons that match the intended meaning.
Examples of allowed uses:
if value is None
if value is not None
if len(items) == 0
if len(items) > 0
if count == 0
if count != 0
if count > 0
# Boolean values
if flag
if not flagExamples of forbidden uses:
if value
if not value
while value
return value or defaultReplacement guide:
| Case | Use |
|---|---|
| optional value | value is not None |
| collection | len(value) > 0 |
| number | value != 0 |
| boolean | value |
- Run tests using
uv. - Test files must be placed in the
testsdirectory, mirroring the structure of thesrcdirectory. - Test names must start with
test_, be followed by a verb in present tense, and read asThe test should.... The names mustn't include the word "should", and they must be descriptive and concise, avoiding the inclusion of the tested function whenever possible. Examples:test_create_user,test_fail_when_creating_user_with_untrusted_email,test_ban_user_using_administrator_account. - Append new test cases to the end of the existing ones.
- When mocks are needed, use
MockerFixture. MockerFixtureshould use thecreate_autospecmethod to create mocks, and theinstance=Trueparameter should be passed to ensure the mock behaves like an instance of the class being mocked.mocker.Mock()should be avoided, as it creates a generic mock that doesn't enforce the interface of the mocked class. UseMockerFixtureinstead ofmonkeypatch.- When patching, don't hardcode the path. If you have to reference a module, use
__module__, and if you have to reference a method, use__name__. For example, instead ofmocker.patch("HostEnvironment.inspect.currentframe"), usemocker.patch(f"{HostEnvironment.__module__}.{inspect.__name__}.{inspect.currentframe.__name__}"). Also, when patching, useautospec=Trueto ensure the mock behaves like the original object.
- Use American English.
- The documentation must be placed in the
docsdirectory or theREADMEfile. - Use "we" to refer to the reader and the author together.