diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5ef2b1033..81d9415ad 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,12 @@ +# Rely on pre-commit.ci instead name: Lint via pre-commit on: - pull_request: - push: - branches-ignore: - - main + workflow_dispatch: + # pull_request: + # push: + # branches-ignore: + # - main permissions: contents: read diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f4fac317..d995f4253 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ repos: - id: black - id: black-jupyter - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.264 + rev: v0.0.265 hooks: - id: ruff args: [--fix-only, --show-fixes] @@ -86,7 +86,7 @@ repos: additional_dependencies: [tomli] files: ^(graphblas|docs)/ - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.264 + rev: v0.0.265 hooks: - id: ruff - repo: https://github.com/sphinx-contrib/sphinx-lint diff --git a/MANIFEST.in b/MANIFEST.in index bdba30a31..27cd3f0c4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,7 @@ recursive-include graphblas *.py prune docs prune scripts include setup.py +include conftest.py include README.md include LICENSE include MANIFEST.in diff --git a/graphblas/tests/conftest.py b/graphblas/tests/conftest.py index a4df5d336..0d1f4008a 100644 --- a/graphblas/tests/conftest.py +++ b/graphblas/tests/conftest.py @@ -18,26 +18,31 @@ def pytest_configure(config): rng = np.random.default_rng() - randomly = config.getoption("--randomly", False) + randomly = config.getoption("--randomly", None) + if randomly is None: # pragma: no cover + options_unavailable = True + randomly = True + config.addinivalue_line("markers", "slow: Skipped unless --runslow passed") + else: + options_unavailable = False backend = config.getoption("--backend", None) if backend is None: if randomly: backend = "suitesparse" if rng.random() < 0.5 else "suitesparse-vanilla" else: backend = "suitesparse" - blocking = config.getoption("--blocking", True) + blocking = config.getoption("--blocking", None) if blocking is None: # pragma: no branch blocking = rng.random() < 0.5 if randomly else True record = config.getoption("--record", False) if record is None: # pragma: no branch record = rng.random() < 0.5 if randomly else False - mapnumpy = config.getoption("--mapnumpy", False) + mapnumpy = config.getoption("--mapnumpy", None) if mapnumpy is None: mapnumpy = rng.random() < 0.5 if randomly else False - runslow = config.getoption("--runslow", False) + runslow = config.getoption("--runslow", None) if runslow is None: - # Add a small amount of randomization to be safer - runslow = rng.random() < 0.05 if randomly else False + runslow = options_unavailable config.runslow = runslow gb.config.set(autocompute=False, mapnumpy=mapnumpy) diff --git a/graphblas/tests/test_core.py b/graphblas/tests/test_core.py index ae2051145..003affc6c 100644 --- a/graphblas/tests/test_core.py +++ b/graphblas/tests/test_core.py @@ -83,7 +83,10 @@ def test_packages(): if not pyproject.exists(): # pragma: no cover (safety) pytest.skip("Did not find pyproject.toml") with pyproject.open("rb") as f: - pkgs2 = sorted(tomli.load(f)["tool"]["setuptools"]["packages"]) + cfg = tomli.load(f) + if cfg.get("project", {}).get("name") != "python-graphblas": # pragma: no cover (safety) + pytest.skip("Did not find correct pyproject.toml") + pkgs2 = sorted(cfg["tool"]["setuptools"]["packages"]) assert ( pkgs == pkgs2 ), "If there are extra items on the left, add them to pyproject.toml:tool.setuptools.packages" diff --git a/graphblas/tests/test_op.py b/graphblas/tests/test_op.py index c9a176afd..a80012ab7 100644 --- a/graphblas/tests/test_op.py +++ b/graphblas/tests/test_op.py @@ -225,7 +225,7 @@ def plus_one(x): UnaryOp.register_new("bad", object()) assert not hasattr(unary, "bad") with pytest.raises(UdfParseError, match="Unable to parse function using Numba"): - UnaryOp.register_new("bad", lambda x: v) + UnaryOp.register_new("bad", lambda x: v) # pragma: no branch (numba) @pytest.mark.skipif("not supports_udfs") diff --git a/graphblas/tests/test_vector.py b/graphblas/tests/test_vector.py index ab019b734..bd2083fd1 100644 --- a/graphblas/tests/test_vector.py +++ b/graphblas/tests/test_vector.py @@ -858,7 +858,7 @@ def inner(x, idx, _, thunk): # pragma: no cover (numba) delattr(indexunary, "iin") delattr(select, "iin") with pytest.raises(UdfParseError, match="Unable to parse function using Numba"): - indexunary.register_new("bad", lambda x, row, col, thunk: result) + indexunary.register_new("bad", lambda x, row, col, thunk: result) # pragma: no branch def test_reduce(v): @@ -2425,7 +2425,7 @@ def test_lambda_udfs(v): # with pytest.raises(TypeError): v.ewise_add(v, lambda x, y: x + y) # pragma: no branch (numba) with pytest.raises(TypeError): - v.inner(v, lambda x, y: x + y) + v.inner(v, lambda x, y: x + y) # pragma: no branch (numba) def test_get(v):