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 1 commit
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
6 changes: 4 additions & 2 deletions google/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import List

try:
import pkg_resources # type: ignore
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
__path__: List[str] = pkgutil.extend_path(__path__, __name__)
4 changes: 2 additions & 2 deletions google/cloud/bigtable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@


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

__version__ : Optional[str]
__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/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
BigtableTableAdminGrpcTransport,
)

from google.cloud.bigtable import __version__
from google.cloud.bigtable import __version__
from google.cloud.bigtable.instance import Instance
from google.cloud.bigtable.cluster import Cluster

Expand Down
13 changes: 7 additions & 6 deletions google/cloud/bigtable/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,10 +1043,6 @@ class _RetryableMutateRowsWorker(object):
are retryable, any subsequent call on this callable will be a no-op.
"""

RETRY_CODES = tuple(
crwilcox marked this conversation as resolved.
Show resolved Hide resolved
retryable.grpc_status_code.value[0] for retryable in RETRYABLE_MUTATION_ERRORS
)

def __init__(self, client, table_name, rows, app_profile_id=None, timeout=None):
self.client = client
self.table_name = table_name
Expand Down Expand Up @@ -1083,7 +1079,12 @@ def __call__(self, retry=DEFAULT_RETRY):

@staticmethod
def _is_retryable(status):
return status is None or status.code in _RetryableMutateRowsWorker.RETRY_CODES
RETRY_CODES = tuple(
retryable.grpc_status_code.value[0]
for retryable in RETRYABLE_MUTATION_ERRORS
)
crwilcox marked this conversation as resolved.
Show resolved Hide resolved

return status is None or status.code in RETRY_CODES

def _do_mutate_retryable_rows(self):
"""Mutate all the rows that are eligible for retry.
Expand Down Expand Up @@ -1128,7 +1129,7 @@ def _do_mutate_retryable_rows(self):
**kwargs
)
except RETRYABLE_MUTATION_ERRORS:
# If an exception, considered retryable by `RETRY_CODES`, is
# If an exception, considered retryable by `RETRYABLE_MUTATION_ERRORS`, is
# returned from the initial call, consider
# it to be retryable. Wrap as a Bigtable Retryable Error.
raise _BigtableRetryableError
Expand Down
5 changes: 2 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ 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.install("mypy", "types-setuptools")
# TODO: also verify types on tests
session.run("mypy", "-p", "google.cloud.bigtable", "--no-incremental")


Expand Down
14 changes: 3 additions & 11 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,10 @@ 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"
)
session.install("mypy", "types-setuptools")
# TODO: also verify types on tests
session.run("mypy", "-p", "google", "--no-incremental")


@nox.session(python=DEFAULT_PYTHON_VERSION)
Expand Down