Frappe Custom DocTypes and Type Checking Setup Explained

frappe custom docType with type-checking

How to Enable Custom DocTypes with Type Checking in Frappe

Frappe Python
Frappe hooks
DocType
frappe type annotations
Frappe hooks.py
Frappe DocType
frappe Developer
Type-checking in Frappe

When creating a new DocType in Frappe, you might notice that the Custom checkbox is non-interactable (read-only).

Custom settings read-only in Frappe

This happens if developer_mode is not active and the developer_mode parameter is set to 1 in the site_config.json file.

Developer mode in Frappe app

If the Custom setting is unchecked, the DocType will store document data in the codebase of the specified app.

Directory and files created after DocType creation with Custom unchecked

Custom DocType with Type-Checking

When creating a non-custom DocType, you’ll notice a simple .py file for form manipulation. However, type-checking is not enabled by default.

DocType Python file

To enable type-checking by default, you need to modify the hooks.py file within your app, located at:

[yourFrappeBenchFolder]/apps/[yourAppName]/[yourAppName]/hooks.py

Add the following configuration:

# For type-checking
export_python_type_annotations = True

Frappe hooks file setting for type annotations

Finally, navigate to your DocType, update any field names, and save the DocType.