Skip to content

Commit 3614e37

Browse files
committed
Remove ABC subscript type arg to support Python < 3.9.
1 parent 589d8bb commit 3614e37

File tree

2 files changed

+49
-34
lines changed

2 files changed

+49
-34
lines changed

client/bqms_run/gcp/gcs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def set_as_default_client(self) -> None:
5353
cloudpathlib.GSClient._default_client = self # type: ignore[misc] # pylint: disable=protected-access
5454

5555
def _download_file(
56-
self, cloud_path: cloudpathlib.GSPath, local_path: Union[str, os.PathLike[Any]]
56+
self,
57+
cloud_path: cloudpathlib.GSPath,
58+
# Subscript type arg not supported on ABCs in Python < 3.9.
59+
local_path: Union[str, os.PathLike], # type: ignore[type-arg]
5760
) -> Path:
5861
"""Override to use bucket.blob instead of bucket.get_blob.
5962
@@ -84,7 +87,11 @@ class GSPath(cloudpathlib.GSPath):
8487

8588
client: GSClient
8689

87-
def download_to(self, destination: Union[str, os.PathLike[Any]]) -> Path:
90+
def download_to(
91+
self,
92+
# Subscript type arg not supported on ABCs in Python < 3.9.
93+
destination: Union[str, os.PathLike], # type: ignore[type-arg]
94+
) -> Path:
8895
"""Download GSPath to local cache."""
8996
destination = Path(destination)
9097
if destination.is_dir():

client/noxfile.py

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
"""Dev commands."""
1515
import pathlib
16+
import tempfile
1617

1718
import nox
1819

@@ -51,38 +52,45 @@ def type_check(session):
5152
@nox.session(python=["3.7", "3.8", "3.9", "3.10"])
5253
def tests(session):
5354
"""Execute tests."""
54-
session.install("poetry")
55-
session.run("poetry", "install")
56-
tests_path = pathlib.Path("tests")
57-
if "unit" in session.posargs:
58-
tests_path = tests_path / "unit"
59-
if "integration" in session.posargs:
60-
tests_path = tests_path / "integration"
61-
if "pytest_verbose" in session.posargs:
62-
session.run(
63-
"poetry",
64-
"run",
65-
"coverage",
66-
"run",
67-
"--source=bqms_run",
68-
"-m",
69-
"pytest",
70-
"-vv",
71-
"--log-cli-level=INFO",
72-
"--log-cli-format="
73-
"%(asctime)s: %(levelname)s: %(threadName)s: "
74-
"%(filename)s:%(lineno)s: %(message)s",
75-
tests_path.as_posix(),
76-
)
77-
else:
55+
with tempfile.NamedTemporaryFile() as temp_file:
56+
session.install("poetry")
7857
session.run(
7958
"poetry",
80-
"run",
81-
"coverage",
82-
"run",
83-
"--source=bqms_run",
84-
"-m",
85-
"pytest",
86-
tests_path.as_posix(),
59+
"export",
60+
"--with",
61+
"dev",
62+
"--without-hashes",
63+
"--output",
64+
temp_file.name,
8765
)
88-
session.run("poetry", "run", "coverage", "report", "-m")
66+
session.install("-r", temp_file.name)
67+
session.install(".")
68+
tests_path = pathlib.Path("tests")
69+
if "unit" in session.posargs:
70+
tests_path = tests_path / "unit"
71+
if "integration" in session.posargs:
72+
tests_path = tests_path / "integration"
73+
if "pytest_verbose" in session.posargs:
74+
session.run(
75+
"coverage",
76+
"run",
77+
"--source=bqms_run",
78+
"-m",
79+
"pytest",
80+
"-vv",
81+
"--log-cli-level=INFO",
82+
"--log-cli-format="
83+
"%(asctime)s: %(levelname)s: %(threadName)s: "
84+
"%(filename)s:%(lineno)s: %(message)s",
85+
tests_path.as_posix(),
86+
)
87+
else:
88+
session.run(
89+
"coverage",
90+
"run",
91+
"--source=bqms_run",
92+
"-m",
93+
"pytest",
94+
tests_path.as_posix(),
95+
)
96+
session.run("coverage", "report", "-m")

0 commit comments

Comments
 (0)