Skip to content

unresolved-import for google.cloud packages #363

@galah92

Description

@galah92

Summary

➜  Downloads uv init tytest
Initialized project `tytest` at `/Users/galah92/Downloads/tytest`
➜  Downloads cd tytest
➜  tytest git:(main) ✗ uv add ty google-cloud-pubsub
Using CPython 3.13.3 interpreter at: /opt/homebrew/opt/[email protected]/bin/python3.13
Creating virtual environment at: .venv
Resolved 28 packages in 406ms
Installed 27 packages in 54ms
...

Then edit main.py with the first example from here:

import os
from google.cloud import pubsub_v1

publisher = pubsub_v1.PublisherClient()
topic_name = 'projects/{project_id}/topics/{topic}'.format(
    project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
    topic='MY_TOPIC_NAME',  # Set this to something appropriate.
)
publisher.create_topic(name=topic_name)
future = publisher.publish(topic_name, b'My first message!', spam='eggs')
future.result()

And

➜  tytest git:(main) ✗ uv run ty check
WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
error[unresolved-import]: Cannot resolve imported module `google.cloud`
 --> main.py:2:6
  |
1 | import os
2 | from google.cloud import pubsub_v1
  |      ^^^^^^^^^^^^
3 |
4 | publisher = pubsub_v1.PublisherClient()
  |
info: rule `unresolved-import` is enabled by default

Found 1 diagnostic

I demonstrated here the issue with google-cloud-pubsub but I see it happening in my project with google-cloud-bigquery and other google-cloud-* packages.

Version

ty 0.0.1-alpha.1 (12f466e 2025-05-13)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingimportsModule resolution, site-packages discovery, import-related diagnostics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions