|
34 | 34 |
|
35 | 35 | MYPY_VERSION = "mypy==1.10.0" |
36 | 36 |
|
| 37 | +MYPY_VERSION = "mypy==1.10.0" |
| 38 | + |
37 | 39 | DEFAULT_PYTHON_VERSION = "3.8" |
38 | 40 |
|
39 | 41 | UNIT_TEST_PYTHON_VERSIONS: List[str] = [ |
|
87 | 89 | "mypy", |
88 | 90 | # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 |
89 | 91 | # "mypy_samples", # TODO: uncomment when the check passes |
| 92 | + "mypy", |
| 93 | + # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 |
| 94 | + # "mypy_samples", # TODO: uncomment when the check passes |
| 95 | + # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 |
| 96 | + # "mypy_samples", # TODO: uncomment when the check passes |
90 | 97 | "docs", |
91 | 98 | "docfx", |
92 | 99 | "format", |
@@ -143,6 +150,77 @@ def mypy_samples(session): |
143 | 150 | ) |
144 | 151 |
|
145 | 152 |
|
| 153 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 154 | +def mypy(session): |
| 155 | + """Run type checks with mypy.""" |
| 156 | + session.install("-e", ".[all]") |
| 157 | + session.install(MYPY_VERSION) |
| 158 | + |
| 159 | + # Version 2.1.1 of google-api-core version is the first type-checked release. |
| 160 | + # Version 2.2.0 of google-cloud-core version is the first type-checked release. |
| 161 | + session.install( |
| 162 | + "google-api-core[grpc]>=2.1.1", |
| 163 | + "google-cloud-core>=2.2.0", |
| 164 | + ) |
| 165 | + |
| 166 | + # Just install the type info directly, since "mypy --install-types" might |
| 167 | + # require an additional pass. |
| 168 | + # Exclude types-protobuf==4.24.0.20240106 |
| 169 | + # See https://github.com/python/typeshed/issues/11254 |
| 170 | + session.install("types-protobuf!=4.24.0.20240106", "types-setuptools") |
| 171 | + |
| 172 | + # TODO: Only check the hand-written layer, the generated code does not pass |
| 173 | + # mypy checks yet. |
| 174 | + # https://github.com/googleapis/gapic-generator-python/issues/1092 |
| 175 | + session.run("mypy", "-p", "google.cloud") |
| 176 | + |
| 177 | + |
| 178 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 179 | +def mypy_samples(session): |
| 180 | + """Run type checks with mypy.""" |
| 181 | + |
| 182 | + session.install("-e", ".[all]") |
| 183 | + |
| 184 | + session.install("pytest") |
| 185 | + session.install(MYPY_VERSION) |
| 186 | + |
| 187 | + # Just install the type info directly, since "mypy --install-types" might |
| 188 | + # require an additional pass. |
| 189 | + session.install("types-mock", "types-protobuf", "types-setuptools") |
| 190 | + |
| 191 | + session.run( |
| 192 | + "mypy", |
| 193 | + "--config-file", |
| 194 | + str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), |
| 195 | + "--no-incremental", # Required by warn-unused-configs from mypy.ini to work |
| 196 | + "samples/", |
| 197 | + ) |
| 198 | + |
| 199 | + |
| 200 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 201 | +def mypy_samples(session): |
| 202 | + """Run type checks with mypy.""" |
| 203 | + |
| 204 | + session.install("-e", ".[all]") |
| 205 | + |
| 206 | + session.install("pytest") |
| 207 | + session.install(MYPY_VERSION) |
| 208 | + |
| 209 | + # Just install the type info directly, since "mypy --install-types" might |
| 210 | + # require an additional pass. |
| 211 | + session.install("types-mock", "types-protobuf", "types-setuptools") |
| 212 | + |
| 213 | + session.run( |
| 214 | + "mypy", |
| 215 | + # https://github.com/googleapis/python-pubsub/pull/552#issuecomment-1016256936 |
| 216 | + # "mypy_samples", # TODO: uncomment when the check passes |
| 217 | + "--config-file", |
| 218 | + str(CURRENT_DIRECTORY / "samples" / "snippets" / "mypy.ini"), |
| 219 | + "--no-incremental", # Required by warn-unused-configs from mypy.ini to work |
| 220 | + "samples/", |
| 221 | + ) |
| 222 | + |
| 223 | + |
146 | 224 | @nox.session(python=DEFAULT_PYTHON_VERSION) |
147 | 225 | def lint(session): |
148 | 226 | """Run linters. |
@@ -251,7 +329,7 @@ def unit(session, protobuf_implementation): |
251 | 329 | "py.test", |
252 | 330 | "--quiet", |
253 | 331 | f"--junitxml=unit_{session.python}_sponge_log.xml", |
254 | | - "--cov=google/cloud", |
| 332 | + "--cov=google/cloud/cloud", |
255 | 333 | "--cov=tests/unit", |
256 | 334 | "--cov-append", |
257 | 335 | "--cov-config=.coveragerc", |
|
0 commit comments