Skip to content

stbutest: option to use it with pandas nightly #184

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

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ help = "Run pyright on 'tests' using the installed stubs"
script = "scripts.test:test(dist=True, type_checker='pyright')"

[tool.poe.tasks.stubtest]
script = "scripts.test:stubtest(allowlist, check_missing)"
script = "scripts.test:stubtest(allowlist, check_missing, nightly)"
help = "Run stubtest to compare the installed stubs against pandas"
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)"}]
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)"}]


[tool.black]
Expand Down
7 changes: 5 additions & 2 deletions scripts/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ def test(
run_job(steps)


def stubtest(allowlist: str, check_missing: bool):
def stubtest(allowlist: str, check_missing: bool, nightly: bool) -> None:
stubtest = dataclasses.replace(
_step.stubtest,
run=partial(
_step.stubtest.run, allowlist=allowlist, check_missing=check_missing
),
)
run_job(_DIST_STEPS[:2] + [stubtest])
steps = _DIST_STEPS[:2]
if nightly:
steps.append(_step.nightly)
run_job(steps + [stubtest])
3 changes: 3 additions & 0 deletions scripts/test/_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@
stubtest = Step(
name="Run stubtest to compare the installed stubs against pandas", run=run.stubtest
)
nightly = Step(
name="Install pandas nightly", run=run.nightly_pandas, rollback=run.released_pandas
)
26 changes: 24 additions & 2 deletions scripts/test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def build_dist():

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


Expand All @@ -69,7 +69,7 @@ def pyright_dist():


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


Expand All @@ -78,3 +78,25 @@ def restore_src():
Path(r"_pandas-stubs").rename("pandas-stubs")
else:
raise FileNotFoundError("'_pandas-stubs' folder does not exists.")


def nightly_pandas():
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas"]
subprocess.run(cmd, check=True)
cmd = [
sys.executable,
"-m",
"pip",
"install",
"-i",
"https://pypi.anaconda.org/scipy-wheels-nightly/simple",
"pandas",
]
subprocess.run(cmd, check=True)


def released_pandas():
cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "pandas"]
subprocess.run(cmd, check=True)
cmd = [sys.executable, "-m", "pip", "install", "pandas"]
subprocess.run(cmd, check=True)