unref 0.2.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unref
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Rust
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Summary: Find unreferenced Python code
|
|
16
|
+
Keywords: dead-code,unused-code,linter,static-analysis
|
|
17
|
+
Author: Yossi Rozantsev
|
|
18
|
+
License-Expression: MIT
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
21
|
+
Project-URL: documentation, https://unref.readthedocs.io/
|
|
22
|
+
Project-URL: homepage, https://github.com/Apakottur/unref
|
|
23
|
+
Project-URL: repository, https://github.com/Apakottur/unref
|
|
24
|
+
|
|
25
|
+
[](https://pypi.python.org/pypi/unref)
|
|
26
|
+
[](https://github.com/Apakottur/unref/blob/main/LICENSE)
|
|
27
|
+
[](https://pypi.python.org/pypi/unref)
|
|
28
|
+
[](https://unref.readthedocs.io/)
|
|
29
|
+
|
|
30
|
+
# unref
|
|
31
|
+
|
|
32
|
+
Find dead code in Python projects: the unused functions, classes, methods, variables and attributes that
|
|
33
|
+
nothing references.
|
|
34
|
+
|
|
35
|
+
**Documentation**: [unref.readthedocs.io](https://unref.readthedocs.io/)
|
|
36
|
+
|
|
37
|
+
## Why
|
|
38
|
+
|
|
39
|
+
Unused code piles up in every codebase, faster than ever now that AI tools write much of it.
|
|
40
|
+
|
|
41
|
+
[Ruff](https://docs.astral.sh/ruff/) does not find unused code yet, see
|
|
42
|
+
[astral-sh/ruff#872](https://github.com/astral-sh/ruff/issues/872). `unref` fills that gap until it does:
|
|
43
|
+
|
|
44
|
+
- **Just works**: built-in rules for pytest, unittest, Pydantic, SQLAlchemy and FastAPI, so most projects need
|
|
45
|
+
little or no configuration.
|
|
46
|
+
- **Ruff-style**: same conventions, options and output style, and it covers what Ruff leaves out.
|
|
47
|
+
- **Fast**: written in Rust on Ruff's parser, it checks all of CPython in under a second.
|
|
48
|
+
- **Modern**: ty-style rule codes and configuration in `pyproject.toml`.
|
|
49
|
+
|
|
50
|
+
## Quick start
|
|
51
|
+
|
|
52
|
+
Run it with [`uvx`](https://docs.astral.sh/uv/):
|
|
53
|
+
|
|
54
|
+
```shell
|
|
55
|
+
$ uvx unref
|
|
56
|
+
src/project/models.py:12:7: unused-class 'Account'
|
|
57
|
+
src/project/utils.py:40:5: unused-function 'parse_date'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or as a [pre-commit](https://pre-commit.com/) or [prek](https://prek.j178.dev/) hook, alongside
|
|
61
|
+
[Ruff](https://docs.astral.sh/ruff/):
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
repos:
|
|
65
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
66
|
+
rev: v0.17.4
|
|
67
|
+
hooks:
|
|
68
|
+
- id: ruff-check
|
|
69
|
+
- id: ruff-format
|
|
70
|
+
- repo: https://github.com/Apakottur/unref
|
|
71
|
+
rev: v0.1.0 # Or run `pre-commit autoupdate`.
|
|
72
|
+
hooks:
|
|
73
|
+
- id: unref
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## How it works
|
|
77
|
+
|
|
78
|
+
- **Matched by module**: a function, class or variable is used only when its own module reads it, or
|
|
79
|
+
another module reaches it through an import, `module.name` or `__all__`.
|
|
80
|
+
- **Installed base classes**: base classes from the project's environment are followed, so the methods a
|
|
81
|
+
subclass overrides count as used.
|
|
82
|
+
- **Ignore comments by code**: `# unref: ignore[...]` names the rule it ignores, and a comment that ignores
|
|
83
|
+
nothing is reported.
|
|
84
|
+
|
|
85
|
+
## Benchmark
|
|
86
|
+
|
|
87
|
+
Checking the whole [CPython](https://github.com/python/cpython) codebase (v3.14.0, about 2,100 files):
|
|
88
|
+
|
|
89
|
+
| Tool | Time |
|
|
90
|
+
| -------------------------------------------------- | ------ |
|
|
91
|
+
| unref | 0.94s |
|
|
92
|
+
| unref (one thread) | 1.59s |
|
|
93
|
+
| [vulture](https://github.com/jendrikseipp/vulture) | 19.68s |
|
|
94
|
+
|
|
95
|
+
Measured with [`scripts/benchmark.py`](https://github.com/Apakottur/unref/blob/main/scripts/benchmark.py).
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
False positives and other bugs are welcome as [issues](https://github.com/Apakottur/unref/issues). To
|
|
100
|
+
contribute code, see [CONTRIBUTING.md](https://github.com/Apakottur/unref/blob/main/CONTRIBUTING.md).
|
|
101
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
unref-0.2.0.data/scripts/unref.exe,sha256=hRIInUSX4TfIDluocywesfep2TxaotR2QCE6HCIy86A,5623296
|
|
2
|
+
unref-0.2.0.dist-info/METADATA,sha256=aXizztGQIrlimo_jXUBSvrX6iHWi7m2f5uYVAe5bKkU,4177
|
|
3
|
+
unref-0.2.0.dist-info/WHEEL,sha256=Uvw7WSmy7Kj2FBk8Va4L_dq4MDW8X5Ynby-pOX3ZNS0,94
|
|
4
|
+
unref-0.2.0.dist-info/licenses/LICENSE,sha256=vis7r9aFvXCjdY5RY2_n8vUJ5QpTrGoAsPwFFmGYalY,1093
|
|
5
|
+
unref-0.2.0.dist-info/sboms/unref.cyclonedx.json,sha256=WYMWS3fsH_oymI7FHzXFrN4FvPCgAQBia82TcPJmpeY,125555
|
|
6
|
+
unref-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yossi Rozantsev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|