Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cloud.logging] CloudLoggingHandler: bad typing for constructor (transport's type is inferred as type[BackgroundThreadTransport]) #901

Closed
evil-shrike opened this issue Jun 3, 2024 · 0 comments · Fixed by #903
Assignees
Labels
api: logging Issues related to the googleapis/python-logging API.

Comments

@evil-shrike
Copy link

VSCode's Python plugin can't understand the type of transport argument for CloudLoggingHandler's constructor. It expects to see BackgroundThreadTransport class instead of base.Transport.
So a call with SyncTransport is reported as an error:

import google.cloud.logging
from google.cloud.logging.handlers import CloudLoggingHandler, setup_logging
from google.cloud.logging.handlers.transports import SyncTransport

client = google.cloud.logging.Client()
handler = CloudLoggingHandler(client, name=LOGGER_NAME, transport=SyncTransport)

Argument of type "type[SyncTransport]" cannot be assigned to parameter "transport" of type "type[BackgroundThreadTransport]" in function "init"
"type[SyncTransport]" is incompatible with "type[BackgroundThreadTransport]"

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/python-logging API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants