Skip to main content

Needy logo

CI Coverage PyPI Python License

Needy

A tiny library for writing tests that depend on optional packages, without having everything crash when a package you need is just not there…

Installation

Python 3.11+ is required.

pip install pyneedy  # needy was already taken ( ╥_╥)

Quick Start

Define a probe for the optional dependency you want to use, like JAX:

def jax_module() -> None:
    import jax as jax

Then just mark the tests that need it with @needs.to_run(...):

from needy import needs


@needs.to_run(jax_module)
def test_that_uses_jax() -> None:
    import jax.numpy as jnp

    assert jnp.array([1.0, 2.0]).sum() == 3.0

If jax is installed, the test runs. If it isn't, the test is just skipped instead of crashing the whole suite. Yay!

For optional imports at the top of a file (which would normally fail at collection time), use needs.modules(...). See the docs for more.

Documentation

Getting started The basics: probes and @needs.to_run(...)
Optional imports Handle missing modules at import time with needs.modules
Subtests Mix required and optional paths in one test
API reference Every type and function in one place

Development

Prerequisites:

  • Python >= 3.11
  • uv (recommended) or pip
  • just (optional, for convenience)

Get set up:

git clone https://gitlab.com/pytooling/needy.git
cd needy
uv sync
uv run pre-commit install

Run all checks (lint, format, type-check, tests):

just check

Or manually:

uv run ruff check --fix && uv run ruff format && uv run pyright && uv run pytest

License

MIT, see LICENSE.

Metadata

Release files for pyneedy 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyneedy 1.5.0
File Size Uploaded Provenance Actions
pyneedy-1.5.0.tar.gz 11.5 kB Without provenance Details for pyneedy-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyneedy 1.5.0
File Interpreter ABI Platform Actions
pyneedy-1.5.0-py3-none-any.whl Python 3 none any Details for pyneedy-1.5.0-py3-none-any.whl

Total release size: 25.8 kB

Release files / pyneedy-1.5.0.tar.gz

Download URL pyneedy-1.5.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2a413d0268cce2bfd03dbcc8c3c48366f8186fb8edc7c5329ff66ab3aa9f92ac
BLAKE2b-256 checksum
How to use checksums
75ea263ac7549f92b77e9215d815819ed43af055e21edf7b11f1e25ca061afed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyneedy-1.5.0-py3-none-any.whl

Download URL pyneedy-1.5.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47ea0146777e4e830414eb1a142b7160184cdde2bd12cce4ad8d6044a1809204
BLAKE2b-256 checksum
How to use checksums
1dd727e80de4030f2d94aff70f7b22120f2644ad5c7eb3731127d5b3502c933d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pyneedy 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page