Masonite IDE Helper is a utility for generating Python type hinting stub files (.pyi) for Masonite ORM models. It automates the process of extracting relevant information such as class names, properties, and methods with their return types from model files.
You can install the Masonite IDE Helper via pip:
pip install masonite-ide-helper
To use the Masonite IDE Helper, follow these steps:
-
Import the library:
from masonite_ide_helper import IdeHelper
-
Instantiate the
IdeHelper
class:ide_helper = IdeHelper(models_dir="path/to/models")
If the
models_dir
parameter is not provided, it defaults to the "application/models" directory. -
Call the
make_pyi_files
method:ide_helper.make_pyi_files()
This will generate .pyi files for the models located in the specified directory.
from masonite_ide_helper import IdeHelper
# Instantiate IdeHelper with optional models directory parameter
ide_helper = IdeHelper(models_dir="path/to/models")
# Generate .pyi files for the models
ide_helper.make_pyi_files()
Initializes an instance of IdeHelper.
models_dir
(str | None): The directory path containing the model files. If not provided, defaults to the "application/models" directory.
Generates Python type hinting stub files (.pyi) for the models located in the specified directory.
Retrieves the list of model files from the specified directory and extracts relevant information such as class name, module path, properties, and methods with their return types.
- This library assumes a standard Masonite project structure where models reside in the "application/models" directory. If your project structure differs, you may need to adjust the
models_dir
parameter accordingly. - If any error occurs during the generation of stubs for a model, the error message will be printed, and the process will continue for other models.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! If you find any issues or want to improve the library, feel free to open a pull request or create an issue in the repository.