Skip to content

Commit

Permalink
fix: ignore types for imports generated from 'google.api_core' (#597)
Browse files Browse the repository at this point in the history
Closes #596.
  • Loading branch information
tseaver authored Sep 15, 2020
1 parent b5279ef commit 8440e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gapic/schema/imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def __str__(self) -> str:
answer = f"from {'.'.join(self.package)} {answer}"
if self.alias:
answer += f' as {self.alias}'
if self.module.endswith('_pb2'):
if self.module.endswith('_pb2') or 'api_core' in self.package:
answer += ' # type: ignore'
return answer
5 changes: 5 additions & 0 deletions tests/unit/schema/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def test_str_untyped_pb2():
assert str(i) == 'from foo.bar import baz_pb2 as bacon # type: ignore'


def test_str_untyped_api_core():
i = imp.Import(package=('foo', 'api_core'), module='baz', alias='bacon')
assert str(i) == 'from foo.api_core import baz as bacon # type: ignore'


def test_str_eq():
i1 = imp.Import(package=('foo', 'bar'), module='baz')
i2 = imp.Import(package=('foo', 'bar'), module='baz')
Expand Down

0 comments on commit 8440e09

Please sign in to comment.