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

Using google-cloud-aiplatform alongside google-cloud-bigquery causes google.cloud.bigquery imports to fail mypy #11341

Closed
SanRehmo opened this issue Oct 15, 2021 · 3 comments
Labels
bug mypy got something wrong

Comments

@SanRehmo
Copy link

Bug Report

I'm having an issue where using google-cloud-aiplatform andgoogle-cloud-bigquery in the same project causes google.cloud.bigquery imports to fail mypy.
This is similar to #10360 but caused by a different package.

To Reproduce

With three .py files with the following imports:

script_one.py:

import logging
from google.cloud import bigquery

script_two.py:

import json
import logging

import click
import google
from google.cloud import bigquery

script_three.py:

from google.cloud.aiplatform_v1beta1 import (
    FeaturestoreOnlineServingServiceClient,
    FeaturestoreServiceClient,
)
from google.cloud.aiplatform_v1beta1.services.featurestore_service import (
    FeaturestoreServiceAsyncClient,
)
from google.cloud.aiplatform_v1beta1.types import (
    BigQuerySource,
    FeatureSelector,
    IdMatcher,
    featurestore,
    featurestore_online_service,
    featurestore_service,
)

as well as the requirements.txt file

grpcio==1.40.0
prometheus-client==0.11.0
py-grpc-prometheus==0.7.0
google-cloud-bigquery==2.26.0
google-cloud-aiplatform==1.4.3
ddtrace==0.51.2
pytz~=2021.1
types-pytz~=2021.1.2

Actual Behavior

I get the following errors when running mypy:

script_one.py:6: error: Module "google.cloud" has no attribute "bigquery"
script_two.py:6: error: Module "google.cloud" has no attribute "bigquery"

Changing the import from from google.cloud import bigquery to import google.cloud.bigquery as bigquery as proposed in #10360 (comment) in any one of script_one.py or script_two.py fixes the issue for both of them.

Also, removing all google-cloud-aiplatform imports form script_three.py fixes the issue.

Expected Behavior

I would not expect the usage of one package (google-cloud-aiplatform) to influence the mypy checks of another (google-cloud-bigquery).

Your Environment

  • Mypy version used: 0.910
  • Mypy command-line flags: mypy
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.8.5
  • Operating system and version: CentOS 7.6
@SanRehmo SanRehmo added the bug mypy got something wrong label Oct 15, 2021
@hauntsaninja
Copy link
Collaborator

Does using --namespace-packages fix?

@SanRehmo
Copy link
Author

Does using --namespace-packages fix?

Yes it does, however this causes another errors to appear:

a/b/__init__.py: error: Source file found twice under different module names: "a" and "a.b"

@hauntsaninja
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants