A tool for analyzing Python code
Project description
biston
A structural clone detector for Python code. Written in Rust.
It parses Python files with tree-sitter, normalizes the AST, and finds functions that are structurally similar to each other.
Install
uv add biston
Or build from source:
cargo build --release
Usage
biston <COMMAND>
Commands
biston scan
Scan a directory for code clones.
Usage: biston scan [OPTIONS] [PATH]
Arguments:
[PATH] Directory to scan [default: .]
Options:
--format <FORMAT> Output format [possible values: text, json, sarif]
--min-lines <MIN_LINES> Minimum function length in lines
--threshold <THRESHOLD> Similarity threshold (0.0 - 1.0)
--config <CONFIG> Config file directory (looks for biston.toml or pyproject.toml)
--suggest Generate abstraction suggestions for similar pairs
-h, --help Print help
biston stats
Show statistics about scan findings.
Usage: biston stats [OPTIONS] [PATH]
Arguments:
[PATH] Directory to scan [default: .]
Options:
--format <FORMAT> Output format (text or json) [possible values: text, json, sarif]
--min-lines <MIN_LINES> Minimum function length in lines
--threshold <THRESHOLD> Similarity threshold (0.0 - 1.0)
--config <CONFIG> Config file directory (looks for biston.toml or pyproject.toml)
-h, --help Print help
Configuration
Settings can go in biston.toml or under [tool.biston] in pyproject.toml. If both files exist, biston.toml takes priority. CLI flags override config file settings.
[scan]
| Setting | Default | Description |
|---|---|---|
min_lines |
10 |
Minimum function length in lines |
threshold |
0.7 |
Similarity threshold (0.0–1.0) |
exclude |
["tests/", "**/conftest.py", "migrations/"] |
File patterns to exclude |
include |
["**/*.py"] |
File patterns to include |
[normalization]
| Setting | Default | Description |
|---|---|---|
anonymize_locals |
true |
Replace local variable names |
anonymize_literals |
false |
Replace literal values |
strip_decorators |
true |
Remove decorators from AST |
strip_type_annotations |
true |
Remove type hints |
sort_commutative |
false |
Sort commutative operations |
[output]
| Setting | Default | Description |
|---|---|---|
format |
"text" |
Output format (text, json, or sarif) |
group_overlapping |
true |
Group overlapping clones |
max_results |
50 |
Maximum number of results |
show_source |
true |
Display source code in output |
context_lines |
3 |
Number of context lines around clones |
[suggest]
| Setting | Default | Description |
|---|---|---|
enabled |
false |
Enable suggestion generation |
min_quality |
0.6 |
Minimum template coverage score (0.0–1.0) |
max_holes |
5 |
Maximum holes before suppressing |
render_python |
true |
Render templates as Python source |
[suppress]
| Setting | Default | Description |
|---|---|---|
files |
[] |
File glob patterns to suppress entirely |
Example biston.toml
[scan]
min_lines = 15
threshold = 0.8
exclude = ["vendor/"]
include = ["src/**/*.py"]
[normalization]
anonymize_locals = false
anonymize_literals = true
[output]
format = "json"
max_results = 100
[suggest]
enabled = true
min_quality = 0.8
Inline suppression
You can also suppress findings with Python comments:
# biston: ignore-file— suppress the entire file (must appear in the first 5 lines)# biston: ignore— suppress a single function (place in the function body or on the preceding line)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file biston-0.4.0.tar.gz.
File metadata
- Download URL: biston-0.4.0.tar.gz
- Upload date:
- Size: 78.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
288575eb94d8f2d4b0a71675f4a1feaa6dde54c2a6b54fe0cc8b92a51704476f
|
|
| MD5 |
facd173fc8e9385fa5181a76c04336ea
|
|
| BLAKE2b-256 |
40093a2ca02a0c26857840bbf7cb9d60da88358860db0eceeec3f464daa7bf60
|
Provenance
The following attestation bundles were made for biston-0.4.0.tar.gz:
Publisher:
release.yml on mojzis/biston
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biston-0.4.0.tar.gz -
Subject digest:
288575eb94d8f2d4b0a71675f4a1feaa6dde54c2a6b54fe0cc8b92a51704476f - Sigstore transparency entry: 1293799435
- Sigstore integration time:
-
Permalink:
mojzis/biston@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mojzis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Trigger Event:
push
-
Statement type:
File details
Details for the file biston-0.4.0-py3-none-win_amd64.whl.
File metadata
- Download URL: biston-0.4.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
167176f303120b1f3f8342c18ec809bddf363ce7a45519b1b75fcb8f7ed58916
|
|
| MD5 |
a6ef09708016b0345b234b466d249ac2
|
|
| BLAKE2b-256 |
fd84e9821aa99764ec2750eb83863206e1dba3a9432a7a54941e412d929c8573
|
Provenance
The following attestation bundles were made for biston-0.4.0-py3-none-win_amd64.whl:
Publisher:
release.yml on mojzis/biston
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biston-0.4.0-py3-none-win_amd64.whl -
Subject digest:
167176f303120b1f3f8342c18ec809bddf363ce7a45519b1b75fcb8f7ed58916 - Sigstore transparency entry: 1293799475
- Sigstore integration time:
-
Permalink:
mojzis/biston@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mojzis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Trigger Event:
push
-
Statement type:
File details
Details for the file biston-0.4.0-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: biston-0.4.0-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf95413b902b151c3fd48aa4ef7ae22de35c84147f53ef755172d9d9100327f
|
|
| MD5 |
1f30aec350841163620f045145cb3775
|
|
| BLAKE2b-256 |
91e1b461c81bc590968512ba7aed5d5444240433484412836c0097fa6c36b1fa
|
Provenance
The following attestation bundles were made for biston-0.4.0-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on mojzis/biston
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biston-0.4.0-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
dcf95413b902b151c3fd48aa4ef7ae22de35c84147f53ef755172d9d9100327f - Sigstore transparency entry: 1293799581
- Sigstore integration time:
-
Permalink:
mojzis/biston@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mojzis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Trigger Event:
push
-
Statement type:
File details
Details for the file biston-0.4.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: biston-0.4.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e33d261a4bbb3c95ed9f26c3c449cbe7fc6fddd60b23067c518bc99389f3bbe
|
|
| MD5 |
8576f6763b26f3fb253ed9f40157cd81
|
|
| BLAKE2b-256 |
4b056e180c63824e6d5f3908a8bf2ae652be1c26f19366e159adaff4eba076b3
|
Provenance
The following attestation bundles were made for biston-0.4.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on mojzis/biston
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biston-0.4.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
6e33d261a4bbb3c95ed9f26c3c449cbe7fc6fddd60b23067c518bc99389f3bbe - Sigstore transparency entry: 1293799524
- Sigstore integration time:
-
Permalink:
mojzis/biston@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/mojzis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d027ecbc58a14b30fb9338f5bf9b7bb5fd2b5446 -
Trigger Event:
push
-
Statement type: