DBUtils Type Hint

raw JSON →
0.1.9 verified Fri May 01 auth: no python

Provides type hints for Databricks DBUtils (dbutils), enabling IDE autocompletion and static type checking. Version 0.1.9, maintained as a stub-type package with periodic updates to match Databricks runtime changes.

pip install dbutils-typehint
error AttributeError: module 'dbutils' has no attribute 'fs'
cause dbutils not available in local environment; this package only provides type hints, not runtime implementation.
fix
Run code only in Databricks environment. For local testing, use 'databricks-connect' or mock dbutils.
error ImportError: cannot import name 'dbutils_typehint' from 'dbutils'
cause Incorrect import path: attempting to import from 'dbutils' instead of the top-level package.
fix
Use 'import dbutils_typehint' (not 'from dbutils import ...').
deprecated This package is effectively unmaintained; last release 2022. Use 'dbutils-stubs' or 'databricks-sdk' for newer Databricks runtimes.
fix Switch to 'pip install dbutils-stubs' for Databricks Runtime 10+.
gotcha Import order matters: must import 'dbutils_typehint' BEFORE any use of dbutils. Otherwise type hints won't activate.
fix Place 'import dbutils_typehint' at the very top of your script, before other imports that use dbutils.
gotcha The package relies on monkey-patching and may not work with some IDEs or static type checkers (e.g., Pyright) that enforce strict import restrictions.
fix Consider using 'databricks-connect' or the official Databricks SDK for better type support.

Import the module to activate type hints for dbutils. No direct usage required; the module patches dbutils objects at import time.

import dbutils_typehint
from typing import Optional

# Use dbutils in a typable way
dbutils.fs.ls('/mnt/data')  # Now has type hints enabled
# Explicitly annotate if needed
result: Optional[list] = dbutils.fs.ls('/tmp')