File tree Expand file tree Collapse file tree 5 files changed +61
-10
lines changed Expand file tree Collapse file tree 5 files changed +61
-10
lines changed Original file line number Diff line number Diff line change 14
14
15
15
"""Connections to Google Cloud Datastore API servers."""
16
16
17
- from google .rpc import status_pb2
17
+ from google .rpc import status_pb2 # type: ignore
18
18
19
19
from google .cloud import _http as connection_module
20
- from google .cloud import exceptions
20
+ from google .cloud import exceptions # type: ignore
21
21
from google .cloud .datastore_v1 .types import datastore as _datastore_pb2
22
22
23
23
Original file line number Diff line number Diff line change 17
17
import warnings
18
18
19
19
import google .api_core .client_options
20
- from google .auth .credentials import AnonymousCredentials
21
- from google .cloud ._helpers import _LocalStack
22
- from google .cloud ._helpers import _determine_default_project as _base_default_project
23
- from google .cloud .client import ClientWithProject
20
+ from google .auth .credentials import AnonymousCredentials # type: ignore
21
+ from google .cloud ._helpers import _LocalStack # type: ignore
22
+ from google .cloud ._helpers import _determine_default_project as _base_default_project # type: ignore
23
+ from google .cloud .client import ClientWithProject # type: ignore
24
24
from google .cloud .datastore .version import __version__
25
25
from google .cloud .datastore import helpers
26
26
from google .cloud .datastore ._http import HTTPDatastoreAPI
32
32
33
33
try :
34
34
from google .cloud .datastore ._gapic import make_datastore_api
35
-
36
35
except ImportError : # pragma: NO COVER
37
- from google .api_core import client_info
36
+ from google .api_core import client_info as api_core_client_info
37
+
38
+ def make_datastore_api (client ):
39
+ raise RuntimeError ("No gRPC available" )
38
40
39
- make_datastore_api = None
40
41
_HAVE_GRPC = False
41
- _CLIENT_INFO = client_info .ClientInfo (client_library_version = __version__ )
42
+ _CLIENT_INFO = api_core_client_info .ClientInfo (client_library_version = __version__ )
42
43
else :
43
44
from google .api_core .gapic_v1 import client_info
44
45
Original file line number Diff line number Diff line change
1
+ [mypy]
2
+ python_version = 3.6
3
+ namespace_packages = True
4
+ ignore_missing_imports = True
5
+
6
+ [mypy-google.protobuf]
7
+ ignore_missing_imports = True
Original file line number Diff line number Diff line change 37
37
nox .options .sessions = [
38
38
"unit" ,
39
39
"system" ,
40
+ "mypy" ,
40
41
"cover" ,
41
42
"lint" ,
42
43
"lint_setup_py" ,
@@ -72,6 +73,15 @@ def blacken(session):
72
73
)
73
74
74
75
76
+ @nox .session (python = DEFAULT_PYTHON_VERSION )
77
+ def mypy (session ):
78
+ """Verify type hints are mypy compatible."""
79
+ session .install ("-e" , "." )
80
+ session .install ("mypy" )
81
+ # TODO: also verify types on tests, all of google package
82
+ session .run ("mypy" , "-p" , "google.cloud.datastore" , "--no-incremental" )
83
+
84
+
75
85
@nox .session (python = DEFAULT_PYTHON_VERSION )
76
86
def lint_setup_py (session ):
77
87
"""Verify that setup.py is valid (including RST check)."""
Original file line number Diff line number Diff line change @@ -200,4 +200,37 @@ def docfx(session):
200
200
""" ,
201
201
)
202
202
203
+ # add type checker nox session
204
+ s .replace ("noxfile.py" ,
205
+ """nox.options.sessions = \[
206
+ "unit",
207
+ "system",""" ,
208
+ """nox.options.sessions = [
209
+ "unit",
210
+ "system",
211
+ "mypy",""" ,
212
+ )
213
+
214
+
215
+ s .replace (
216
+ "noxfile.py" ,
217
+ """\
218
+ @nox.session\(python=DEFAULT_PYTHON_VERSION\)
219
+ def lint_setup_py\(session\):
220
+ """ ,
221
+ '''\
222
+ @nox.session(python=DEFAULT_PYTHON_VERSION)
223
+ def mypy(session):
224
+ """Verify type hints are mypy compatible."""
225
+ session.install("-e", ".")
226
+ session.install("mypy")
227
+ # TODO: also verify types on tests, all of google package
228
+ session.run("mypy", "-p", "google.cloud.datastore", "--no-incremental")
229
+
230
+
231
+ @nox.session(python=DEFAULT_PYTHON_VERSION)
232
+ def lint_setup_py(session):
233
+ ''' ,
234
+ )
235
+
203
236
s .shell .run (["nox" , "-s" , "blacken" ], hide_output = False )
You can’t perform that action at this time.
0 commit comments