| name | class-creator |
| description | Use this skill whenever creating or adding a new Python class to the PicoLibrary project. It ensures that the class follows the project's formatting standards, includes the standard file header, uses proper logging, and includes self-contained test execution blocks. |
Class Creator Skill
This skill enforces standards for adding new Python classes to the PicoLibrary repository. All new class files must strictly follow these header and testing guidelines.
1. File Header Template
Every new Python file containing a class MUST begin with a triple-quoted comment block containing the filename, a description of the module/classes, and the author name.
To determine the author name, try running the command git config user.name. If a name is returned, use it in the header. If no name can be retrieved, use the placeholder insert your name here.
Use the following format exactly:
"""
# <Filename>.py
# <A concise description of the file, its purpose, and the classes it implements>
# Author: <Author Name or insert your name here>
"""
Example (if name is found):
"""
# TemperatureSensor.py
# Implementation of a temperature sensor reading from an analog pin
# Author: Arijit Sengupta
"""
Example (if name is not found):
"""
# TemperatureSensor.py
# Implementation of a temperature sensor reading from an analog pin
# Author: insert your name here
"""
2. Coding Standards
- Logging: Use the project's custom
Log utility. Import it as from Log import * and log events using Log.i("Message"). Avoid using raw print() statements for standard operations.
- Imports: Place standard libraries at the top of the file, followed by project-specific imports. Use lazy imports whenever possible, so that the import is only done when a class is instantiated or a method is called. This ensures that the this file can be imported even if the required libraries are not installed on the target device, as long as the function that requires the library is not called.
- Docstrings: Include clear, concise docstrings for the class and all public methods. Use markdown to format the docstrings, including bold, italics, etc. Include examples of how to use the class and its methods. Include a section on Parameters - use the following format:
Parameters:
----------
param1 : type
Description of param1
param2 : type, optional
Description of param2 (default: default_value)
Include a section on Examples - use the following format:
Examples:
---------
1. Example 1
2. Example 2
3. Test Rules
Every new class file must be self-contained and runnable for verification purposes.
Example Test Block:
if __name__ == "__main__":
sensor = TemperatureSensor(pin=26, name="Test Sensor")
val = sensor.readTemp()
Log.i(f"Read temperature: {val}")
Log.i("Testing complete - all checks passed")