Skip to content

Commit 4c2492d

Browse files
authored
stbutest: option to use it with pandas nightly (#184)
1 parent 1ec0bb9 commit 4c2492d

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ help = "Run pyright on 'tests' using the installed stubs"
8989
script = "scripts.test:test(dist=True, type_checker='pyright')"
9090

9191
[tool.poe.tasks.stubtest]
92-
script = "scripts.test:stubtest(allowlist, check_missing)"
92+
script = "scripts.test:stubtest(allowlist, check_missing, nightly)"
9393
help = "Run stubtest to compare the installed stubs against pandas"
94-
args = [{ name = "allowlist", positional = true, default = "", required = false, help= "Path to an allowlist (optional)" }, {name = "check_missing", positional = false, default = false, type = "boolean", required = false, help= "Report errors when the stubs are incomplete (off by default)"}]
94+
args = [{ name = "allowlist", positional = true, default = "", required = false, help= "Path to an allowlist (optional)" }, {name = "check_missing", positional = false, default = false, type = "boolean", required = false, help= "Report errors when the stubs are incomplete (off by default)"}, {name = "nightly", positional = false, default = false, type = "boolean", required = false, help= "Compare against pandas nightly (off by default)"}]
9595

9696

9797
[tool.black]

scripts/test/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ def test(
3535
run_job(steps)
3636

3737

38-
def stubtest(allowlist: str, check_missing: bool):
38+
def stubtest(allowlist: str, check_missing: bool, nightly: bool) -> None:
3939
stubtest = dataclasses.replace(
4040
_step.stubtest,
4141
run=partial(
4242
_step.stubtest.run, allowlist=allowlist, check_missing=check_missing
4343
),
4444
)
45-
run_job(_DIST_STEPS[:2] + [stubtest])
45+
steps = _DIST_STEPS[:2]
46+
if nightly:
47+
steps.append(_step.nightly)
48+
run_job(steps + [stubtest])

scripts/test/_step.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@
2929
stubtest = Step(
3030
name="Run stubtest to compare the installed stubs against pandas", run=run.stubtest
3131
)
32+
nightly = Step(
33+
name="Install pandas nightly", run=run.nightly_pandas, rollback=run.released_pandas
34+
)

scripts/test/run.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def build_dist():
4747

4848
def install_dist():
4949
path = sorted(Path("dist/").glob("pandas_stubs-*.whl"))[-1]
50-
cmd = ["pip", "install", "--force-reinstall", str(path)]
50+
cmd = [sys.executable, "-m", "pip", "install", "--force-reinstall", str(path)]
5151
subprocess.run(cmd, check=True)
5252

5353

@@ -69,7 +69,7 @@ def pyright_dist():
6969

7070

7171
def uninstall_dist():
72-
cmd = ["pip", "uninstall", "-y", "pandas-stubs"]
72+
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas-stubs"]
7373
subprocess.run(cmd, check=True)
7474

7575

@@ -78,3 +78,25 @@ def restore_src():
7878
Path(r"_pandas-stubs").rename("pandas-stubs")
7979
else:
8080
raise FileNotFoundError("'_pandas-stubs' folder does not exists.")
81+
82+
83+
def nightly_pandas():
84+
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas"]
85+
subprocess.run(cmd, check=True)
86+
cmd = [
87+
sys.executable,
88+
"-m",
89+
"pip",
90+
"install",
91+
"-i",
92+
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
93+
"pandas",
94+
]
95+
subprocess.run(cmd, check=True)
96+
97+
98+
def released_pandas():
99+
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas"]
100+
subprocess.run(cmd, check=True)
101+
cmd = [sys.executable, "-m", "pip", "install", "pandas"]
102+
subprocess.run(cmd, check=True)

0 commit comments

Comments
 (0)