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

chore: ensure mypy passes #448

Merged
merged 27 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
53d679f
chore: ensure mypy passes
crwilcox Oct 13, 2021
c2e2b6d
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 13, 2021
65c9024
chore: move type info to inline, not mypy.ini
crwilcox Oct 13, 2021
a55082c
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 13, 2021
b8e02fd
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 13, 2021
2fbaaff
test: add mypy test scenario
crwilcox Oct 13, 2021
470525a
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 13, 2021
3d62bab
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 13, 2021
781784e
chore: simplify type of __version__
crwilcox Oct 13, 2021
d840468
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 13, 2021
9b13a68
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 13, 2021
a93d619
chore: expand typing verification to google namespace
crwilcox Oct 14, 2021
e163ee4
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 14, 2021
daf4ebe
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 14, 2021
3be3a43
chore: remove ignores on api_core module
crwilcox Oct 14, 2021
4bef210
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 14, 2021
0ad8008
chore: no pytype
crwilcox Oct 14, 2021
21cf1f3
chore: scope to just google.cloud.bigtable, defer fixing errors on br…
crwilcox Oct 14, 2021
e3b497e
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 14, 2021
09ddb7f
chore: fix template
crwilcox Oct 14, 2021
3d19a0e
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 14, 2021
a382edb
🦉 Updates from OwlBot
gcf-owl-bot[bot] Oct 14, 2021
d428a0d
chore: lint
crwilcox Oct 14, 2021
590907c
Merge branch 'mypy' of github.com:googleapis/python-bigtable into mypy
crwilcox Oct 14, 2021
6d9a117
fix: break circular import
tseaver Oct 14, 2021
fbdc354
fix: unsnarl typing around list of retryable status codes
tseaver Oct 14, 2021
65a472b
ci: fix coverage gap induced by typing
tseaver Oct 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try:
import pkg_resources
import pkg_resources # type: ignore

pkg_resources.declare_namespace(__name__)
except ImportError:
Expand Down
4 changes: 3 additions & 1 deletion google/cloud/bigtable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"""Google Cloud Bigtable API package."""


import pkg_resources
from typing import Optional
import pkg_resources # type: ignore

__version__: Optional[str]
try:
__version__ = pkg_resources.get_distribution("google-cloud-bigtable").version
tseaver marked this conversation as resolved.
Show resolved Hide resolved
except pkg_resources.DistributionNotFound:
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigtable/app_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from google.cloud.bigtable.enums import RoutingPolicyType
from google.cloud.bigtable_admin_v2.types import instance
from google.protobuf import field_mask_pb2
from google.api_core.exceptions import NotFound
from google.api_core.exceptions import NotFound # type: ignore

_APP_PROFILE_NAME_RE = re.compile(
r"^projects/(?P<project>[^/]+)/"
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

import re

from google.cloud._helpers import _datetime_to_pb_timestamp
from google.cloud._helpers import _datetime_to_pb_timestamp # type: ignore
from google.cloud.bigtable_admin_v2 import BigtableTableAdminClient
from google.cloud.bigtable_admin_v2.types import table
from google.cloud.bigtable.encryption_info import EncryptionInfo
from google.cloud.bigtable.policy import Policy
from google.cloud.exceptions import NotFound
from google.cloud.exceptions import NotFound # type: ignore
from google.protobuf import field_mask_pb2

_BACKUP_NAME_RE = re.compile(
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"""
import os
import warnings
import grpc
import grpc # type: ignore

from google.api_core.gapic_v1 import client_info
import google.auth
from google.auth.credentials import AnonymousCredentials
from google.api_core.gapic_v1 import client_info # type: ignore
crwilcox marked this conversation as resolved.
Show resolved Hide resolved
import google.auth # type: ignore
from google.auth.credentials import AnonymousCredentials # type: ignore

from google.cloud import bigtable_v2
from google.cloud import bigtable_admin_v2
Expand All @@ -49,11 +49,11 @@
from google.cloud.bigtable.instance import Instance
from google.cloud.bigtable.cluster import Cluster

from google.cloud.client import ClientWithProject
from google.cloud.client import ClientWithProject # type: ignore

from google.cloud.bigtable_admin_v2.types import instance
from google.cloud.bigtable.cluster import _CLUSTER_NAME_RE
from google.cloud.environment_vars import BIGTABLE_EMULATOR
from google.cloud.environment_vars import BIGTABLE_EMULATOR # type: ignore


INSTANCE_TYPE_PRODUCTION = instance.Instance.Type.PRODUCTION
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigtable/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import re
from google.cloud.bigtable_admin_v2.types import instance
from google.api_core.exceptions import NotFound
from google.api_core.exceptions import NotFound # type: ignore


_CLUSTER_NAME_RE = re.compile(
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

from google.cloud.bigtable_admin_v2.types import instance

from google.iam.v1 import options_pb2
from google.iam.v1 import options_pb2 # type: ignore

from google.api_core.exceptions import NotFound
from google.api_core.exceptions import NotFound # type: ignore

from google.cloud.bigtable.policy import Policy

Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigtable/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import base64

from google.api_core.iam import Policy as BasePolicy
from google.cloud._helpers import _to_bytes
from google.iam.v1 import policy_pb2
from google.api_core.iam import Policy as BasePolicy # type: ignore
from google.cloud._helpers import _to_bytes # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore

"""IAM roles supported by Bigtable Instance resource"""
BIGTABLE_ADMIN_ROLE = "roles/bigtable.admin"
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigtable/row.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import struct

from google.cloud._helpers import _datetime_from_microseconds
from google.cloud._helpers import _microseconds_from_datetime
from google.cloud._helpers import _to_bytes
from google.cloud._helpers import _datetime_from_microseconds # type: ignore
from google.cloud._helpers import _microseconds_from_datetime # type: ignore
from google.cloud._helpers import _to_bytes # type: ignore
from google.cloud.bigtable_v2.types import data as data_v2_pb2


Expand Down
10 changes: 5 additions & 5 deletions google/cloud/bigtable/row_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import copy

import grpc
import grpc # type: ignore

from google.api_core import exceptions
from google.api_core import retry
from google.cloud._helpers import _datetime_from_microseconds
from google.cloud._helpers import _to_bytes
from google.api_core import exceptions # type: ignore
from google.api_core import retry # type: ignore
from google.cloud._helpers import _datetime_from_microseconds # type: ignore
from google.cloud._helpers import _to_bytes # type: ignore
from google.cloud.bigtable_v2.types import bigtable as data_messages_v2_pb2
from google.cloud.bigtable_v2.types import data as data_v2_pb2

Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable/row_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import struct


from google.cloud._helpers import _microseconds_from_datetime
from google.cloud._helpers import _to_bytes
from google.cloud._helpers import _microseconds_from_datetime # type: ignore
from google.cloud._helpers import _to_bytes # type: ignore
from google.cloud.bigtable_v2.types import data as data_v2_pb2

_PACK_I64 = struct.Struct(">q").pack
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigtable/row_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""User-friendly container for Google Cloud Bigtable RowSet """


from google.cloud._helpers import _to_bytes
from google.cloud._helpers import _to_bytes # type: ignore


class RowSet(object):
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/bigtable/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

import warnings

from google.api_core import timeout
from google.api_core.exceptions import Aborted
from google.api_core import timeout # type: ignore
from google.api_core.exceptions import Aborted # type: ignore
from google.api_core.exceptions import DeadlineExceeded
from google.api_core.exceptions import NotFound
from google.api_core.exceptions import RetryError
from google.api_core.exceptions import ServiceUnavailable
from google.api_core.gapic_v1.method import DEFAULT
from google.api_core.retry import if_exception_type
from google.api_core.gapic_v1.method import DEFAULT # type: ignore
from google.api_core.retry import if_exception_type # type: ignore
from google.api_core.retry import Retry
from google.cloud._helpers import _to_bytes
from google.cloud._helpers import _to_bytes # type: ignore
from google.cloud.bigtable.backup import Backup
from google.cloud.bigtable.column_family import _gc_rule_from_pb
from google.cloud.bigtable.column_family import ColumnFamily
Expand Down
6 changes: 6 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
python_version = 3.6
namespace_packages = True

[mypy-google.protobuf]
ignore_missing_imports = True
12 changes: 12 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"unit",
"system_emulated",
"system",
"mypy",
"pytype",
"cover",
"lint",
"lint_setup_py",
Expand Down Expand Up @@ -72,6 +74,16 @@ def blacken(session):
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""

session.install("-e", ".")
session.install("mypy")

session.run("mypy", "-p", "google.cloud.bigtable", "--no-incremental")


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
Expand Down
33 changes: 32 additions & 1 deletion owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,41 @@ def system_emulated(session):
"""nox.options.sessions = [
"unit",
"system_emulated",
"system",""",
"system",
"mypy",
"pytype",""",
)


s.replace(
"noxfile.py",
"""\
@nox.session\(python=DEFAULT_PYTHON_VERSION\)
def lint_setup_py\(session\):
""",
'''\
@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""

session.install("-e", ".")
session.install(
"mypy"
)

session.run(
"mypy",
"-p",
"google.cloud.bigtable",
"--no-incremental"
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
''',
)

# ----------------------------------------------------------------------------
# Samples templates
# ----------------------------------------------------------------------------
Expand Down