Skip to content

mypy typing issue: Module "google" has no attribute "genai" #61

@Ben-Epstein

Description

@Ben-Epstein

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.

If the support paths suggested above still do not result in a resolution, please provide the following details.

from google import genai

mypy complains Module "google" has no attribute "genai". I think it's because of your namespacing, google has no __init__.py so it's not a package, it's a namespace. So you can do import google.genai as genai but this isn't great, and also incorrect (any linter will replace it will from google import genai`.

So right now you have to do import google.genai and just use it like that, or add a type: ignore on the import. Or, you can update your docs to do from google.genai import Client

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions