ifeval
Evaluate all if-statement predicates in a Python file and simplify the code by removing unreachable branches.
This tool parses a Python source file, evaluates constant if conditions (if f(x), if x is None, etc.), and rewrites the file to include only the branches that would execute.
Installation
Clone the repository and install with pip:
git clone https://gitlab.com/knvvv/ifeval.git
cd ifeval
pip install .
Usage
Dry run (default)
To preview changes without modifying the file:
ifeval path/to/your_script.py
It will print the diff showing what would be changed.
Apply changes
To actually rewrite the file in-place, add the --no-dry flag:
ifeval path/to/your_script.py --no-dry
Example
Given the following code:
print("Hello")
if True:
print("Keep this")
else:
print("Remove this")
ifeval simplifies it to:
print("Hello")
print("Keep this")
⚠️ A word of caution ⚠️
This package executes all the code from files being analyzed. Do not run it on untrusted or potentially malicious code, as it may lead to arbitrary code execution.
Metadata
Release files for ifeval 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ifeval-0.0.1.tar.gz | 4.0 kB | Without provenance | Details for ifeval-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ifeval-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for ifeval-0.0.1-py3-none-any.whl |
Total release size: 8.3 kB
Release files / ifeval-0.0.1.tar.gz
| Download URL | ifeval-0.0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2462f25eea7b51223af660029204e2a2b2049e445ec7d8129014fd66b405fcc
|
|
BLAKE2b-256 checksum How to use checksums |
cbbf771596e2500d8812a58cea37db1066a776925719afee2f5155b52b1a4db1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / ifeval-0.0.1-py3-none-any.whl
| Download URL | ifeval-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26574e39f175b0457e1813d8a926703fa62267daa8d58360785217a5a2f129c2
|
|
BLAKE2b-256 checksum How to use checksums |
79c9fe488f5dbc0dd7358d3030ff6ade74ec3665f4e7815def03a70430214540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for ifeval 0.0.1
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.