{"record":{"id":"9302f9d75c44e14c","repo":"Textualize/textual","slug":"unable-to-import-driver-import-r-driver-class","errorCode":null,"errorMessage":"Unable to import {driver_import!r}; {driver_class!r} is not a Driver class ","messagePattern":"Unable to import (.+?); (.+?) is not a Driver class ","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"src/textual/app.py","lineNumber":1595,"sourceCode":"        building a Textual app.\n\n        Returns:\n            A Driver class which manages input and display.\n        \"\"\"\n\n        driver_class: Type[Driver]\n\n        driver_import = constants.DRIVER\n        if driver_import is not None:\n            # The driver class is set from the environment\n            # Syntax should be foo.bar.baz:MyDriver\n            module_import, _, driver_symbol = driver_import.partition(\":\")\n            driver_module = importlib.import_module(module_import)\n            driver_class = getattr(driver_module, driver_symbol)\n            if not inspect.isclass(driver_class) or not issubclass(\n                driver_class, Driver\n            ):\n                raise RuntimeError(\n                    f\"Unable to import {driver_import!r}; {driver_class!r} is not a Driver class \"\n                )\n            return driver_class\n\n        if WINDOWS:\n            from textual.drivers.windows_driver import WindowsDriver\n\n            driver_class = WindowsDriver\n        else:\n            from textual.drivers.linux_driver import LinuxDriver\n\n            driver_class = LinuxDriver\n        return driver_class\n\n    def __rich_repr__(self) -> rich.repr.Result:\n        yield \"title\", self.title\n        yield \"id\", self.id, None\n        if self.name:","sourceCodeStart":1577,"sourceCodeEnd":1613,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/app.py#L1577-L1613","documentation":"RuntimeError raised in App.get_driver_class when TEXTUAL driver_import resolves to something that is not a Driver subclass. The driver is specified via the TEXTUAL environment variable as 'module:Class'.","triggerScenarios":"Setting TEXTUAL=\"my_module:MyDriver\" where MyDriver is a function or unrelated class; typo in module path; driver class not subclassing textual.driver.Driver.","commonSituations":"Custom driver development, CI environments injecting TEXTUAL, or stale env vars pointing at moved code.","solutions":["Ensure the class subclasses Driver (from textual.driver import Driver) and is exported at module level","Fix the env format: export TEXTUAL=\"my_package.drivers:MyDriver\"","Unset TEXTUAL to use the auto-selected platform driver"],"exampleFix":"# before\n# TEXTUAL=\"my_driver:create\" (factory function)\nclass MyDriver:\n    ...\n\n# after\nfrom textual.driver import Driver\nclass MyDriver(Driver):\n    ...\n# TEXTUAL=\"my_driver:MyDriver\"","handlingStrategy":"validation","validationCode":"import importlib, inspect\nfrom textual.driver import Driver\nmod, _, sym = driver_import.partition(':')\ncls = getattr(importlib.import_module(mod), sym)\nassert inspect.isclass(cls) and issubclass(cls, Driver)","typeGuard":"def is_driver_class(cls) -> bool:\n    import inspect\n    from textual.driver import Driver\n    return inspect.isclass(cls) and issubclass(cls, Driver)","tryCatchPattern":null,"preventionTips":["Format TEXTUAL as 'module:Class'","Subclass textual.driver.Driver","Unset TEXTUAL unless you truly need a custom driver"],"tags":["driver","environment","runtimeerror","textual"],"backgroundTag":"invalid-driver-config","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}