bisect-find-first-bad
git bisect run can only search through commits.
This search don't use git to switch versions. You can check arbitrary options for is_bad.
install
pip install bisect-find-first-bad
usage
you should subclass from BisectFindFirstBad and implement 1 method is_bad or is_good.
This method should return True/False which indicates is option good or bad.
When instantiating your class you should provide a sequence of options to check. They should be sorted by is_bad. Left side of options are good options and on the right are bad ones.
simple example
from bisect_find_first_bad import BisectFindFirstBad
class FirstGreaterThan3(BisectFindFirstBad):
def is_bad(self, op) -> bool:
return op > 3
# or you can use is_good:
class FirstGreaterThan3(BisectFindFirstBad):
def is_good(self, op) -> bool:
return op <= 3
first_greater_than_3 = FirstGreaterThan3(options = (1, 2, 3, 4, 5, 6))
>>> first_greater_than_3.is_bad(2)
False
>>> first_greater_than_3.is_bad(5)
True
>>> first_greater_than_3()
4 start
4: BAD
2 start
2: GOOD
3 start
3: GOOD
====================================================================================================
first bad option is: 4
4
more complex example - find first bad version of poetry dependency
import subprocess
from bisect_find_first_bad import BisectFindFirstBad
class FirstBadDependencyVersion(BisectFindFirstBad):
def is_bad(self, op) -> bool:
# kinda setup
subprocess.check_call(f'git checkout HEAD -- poetry.lock pyproject.toml && poetry add "my_library=={op}"', shell=True)
# check is_bad
return bool(subprocess.run('make test', shell=True).returncode)
first_bad_dependency_version = FirstBadDependencyVersion(options='''\
v0.0.1
v0.0.2
v0.0.3
v0.1.0
v0.1.1
v0.1.2
v0.2.0
v0.2.1
'''.splitlines())
>>> first_bad_dependency_version()
v0.1.1 start
v0.1.1: GOOD
v0.2.0 start
v0.2.0: BAD
v0.1.2 start
v0.1.2: BAD
====================================================================================================
first bad option is: v0.1.2
'v0.1.2'
Metadata
Release files for bisect-find-first-bad 0.0.4
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 |
|---|---|---|---|---|
| bisect-find-first-bad-0.0.4.tar.gz | 3.8 kB | Without provenance | Details for bisect-find-first-bad-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bisect_find_first_bad-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for bisect_find_first_bad-0.0.4-py3-none-any.whl |
Total release size: 7.2 kB
Release files / bisect-find-first-bad-0.0.4.tar.gz
| Download URL | bisect-find-first-bad-0.0.4.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0be9fcec89b402ad80e4f51a8112fef7989955515fff84c7b2426baa7d937cbe
|
|
BLAKE2b-256 checksum How to use checksums |
32ca9ec3d1b030ac647a30117e83255cbbd824ad409aa4753578f6bf833e7c60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / bisect_find_first_bad-0.0.4-py3-none-any.whl
| Download URL | bisect_find_first_bad-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
886b2fc53d8107ffd8470ba6f8cac7c786e1d55a318cfc5369439662c3da0f7b
|
|
BLAKE2b-256 checksum How to use checksums |
2f806f6e1d9255174ab31df84e3c1aff538ecc232959d9ef3e8a29e656b6aa33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for bisect-find-first-bad 0.0.4
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.