{"record":{"id":"4bbc008b1d569ee0","repo":"SeleniumHQ/selenium","slug":"module-name-r-has-no-attribute-name-r-4bbc00","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/safari/__init__.py","lineNumber":28,"sourceCode":"#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\nimport importlib\n\n_LAZY_SUBMODULES = [\"options\", \"permissions\", \"remote_connection\", \"service\", \"webdriver\"]\n\n\ndef __getattr__(name):\n    if name in _LAZY_SUBMODULES:\n        module = importlib.import_module(f\".{name}\", __name__)\n        globals()[name] = module\n        return module\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n\n\ndef __dir__():\n    return sorted(_LAZY_SUBMODULES)\n","sourceCodeStart":10,"sourceCodeEnd":33,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/safari/__init__.py#L10-L33","documentation":"Module-level __getattr__ in selenium.webdriver.safari implements lazy submodule loading for a fixed allowlist (options, permissions, remote_connection, service, webdriver). Accessing any attribute outside that allowlist raises AttributeError naming the module and the missing attribute.","triggerScenarios":"1) selenium.webdriver.safari.<typo> for a name not in the allowlist. 2) hasattr/getattr probes or IDE autocompletion guesses. 3) Migration code expecting an attribute that was renamed/removed.","commonSituations":"Renamed internals across versions, a typo in the import path, or accessing a private name that is not lazily exported.","solutions":["Check spelling against the allowlist: options, permissions, remote_connection, service, webdriver.","Import the submodule directly: `from selenium.webdriver.safari import service`.","Consult the current API docs for the correct public name."],"exampleFix":"# before\nfrom selenium.webdriver import safari\nsvc = safari.srvc   # typo -> AttributeError\n\n# after\nfrom selenium.webdriver.safari import service as svc","handlingStrategy":"validation","validationCode":"from selenium.webdriver import safari\nname = \"service\"\nif name not in dir(safari) and name not in (\"options\",\"permissions\",\"remote_connection\",\"service\",\"webdriver\"):\n    raise AttributeError(f\"safari has no lazy submodule {name}\")","typeGuard":"from selenium.webdriver import safari\n_LAZY = {\"options\",\"permissions\",\"remote_connection\",\"service\",\"webdriver\"}\ndef has_safari_attr(name: str) -> bool:\n    return name in _LAZY","tryCatchPattern":null,"preventionTips":["Use explicit submodule imports rather than attribute access on the package.","Cross-check attribute names against the lazy allowlist before dynamic access."],"tags":["safari","import","lazy-loading","attribute-error"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}