deadcode 2.4.0__tar.gz → 2.5.0__tar.gz
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.
- deadcode-2.4.0/README.md → deadcode-2.5.0/PKG-INFO +56 -0
- deadcode-2.4.0/PKG-INFO → deadcode-2.5.0/README.md +28 -27
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/__init__.py +2 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/parse_arguments.py +6 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/cli.py +11 -1
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/data_types.py +1 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/utils.py +1 -1
- {deadcode-2.4.0 → deadcode-2.5.0}/pyproject.toml +8 -6
- {deadcode-2.4.0 → deadcode-2.5.0}/.gitignore +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/LICENSE +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/__init__.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/find_python_filenames.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/find_unused_names.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/fix_or_show_unused_code.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/get_unused_names_error_message.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/merge_overlaping_file_parts.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/parse_abstract_syntax_tree.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/actions/remove_file_parts_from_content.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/constants.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/__init__.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/add_colors_to_diff.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/base_test_case.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/fix_indent.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/flatten_lists.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/nested_scopes.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/utils/print_ast.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/__init__.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/code_item.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/dead_code_visitor.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/ignore.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/lines.py +0 -0
- {deadcode-2.4.0 → deadcode-2.5.0}/deadcode/visitor/noqa.py +0 -0
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: deadcode
|
|
3
|
+
Version: 2.5.0
|
|
4
|
+
Summary: Find and remove dead code.
|
|
5
|
+
Project-URL: homepage, https://github.com/albertas/deadcode
|
|
6
|
+
Project-URL: documentation, https://deadcode.readthedocs.io/
|
|
7
|
+
Author-email: Albertas Gimbutas <albertasgim@gmail.com>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
11
|
+
Classifier: Natural Language :: English
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: tomli>=2.0.1
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: hatch; extra == 'test'
|
|
21
|
+
Requires-Dist: mypy==1.10.1; extra == 'test'
|
|
22
|
+
Requires-Dist: pip-audit; extra == 'test'
|
|
23
|
+
Requires-Dist: pre-commit; extra == 'test'
|
|
24
|
+
Requires-Dist: pytest-cov==5.0.0; extra == 'test'
|
|
25
|
+
Requires-Dist: pytest==9.0.3; extra == 'test'
|
|
26
|
+
Requires-Dist: ruff==0.5.1; extra == 'test'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
1
29
|
[](https://deadcode.readthedocs.io/en/stable/)
|
|
2
30
|
|
|
3
31
|
<h2 align="center">Find and Fix Unused Python Code</h2>
|
|
@@ -7,6 +35,7 @@
|
|
|
7
35
|
<a href="https://pypi.org/project/deadcode/"><img alt="PyPI" src="https://img.shields.io/pypi/v/deadcode"></a>
|
|
8
36
|
<a href="https://pepy.tech/project/deadcode"><img alt="Downloads" src="https://static.pepy.tech/badge/deadcode"></a>
|
|
9
37
|
<a href="https://github.com/albertas/deadcode/blob/main/LICENSE"><img alt="License: AGPLv3" src="https://raw.githubusercontent.com/albertas/deadcode/main/docs/_static/AGPLv3-license.svg"></a>
|
|
38
|
+
<br/><a href='https://ko-fi.com/V7V21681GD' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi3.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
|
10
39
|
</p>
|
|
11
40
|
|
|
12
41
|
|
|
@@ -49,6 +78,28 @@ ignore-names = ["BaseTestCase", "*Mixin"]
|
|
|
49
78
|
ignore-names-in-files = ["migrations"]
|
|
50
79
|
```
|
|
51
80
|
|
|
81
|
+
## Pre-commit hook
|
|
82
|
+
Create a `.pre-commit-config.yaml` file in the root of your project directory, if it doesn't exist, and add the following to the file:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
# See https://pre-commit.com for more information
|
|
86
|
+
# See https://pre-commit.com/hooks.html for more hooks
|
|
87
|
+
repos:
|
|
88
|
+
- repo: https://github.com/albertas/deadcode
|
|
89
|
+
rev: 2.5.0
|
|
90
|
+
hooks:
|
|
91
|
+
- id: deadcode
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The `rev` is the release tag, so it matches the version published on PyPI. To
|
|
95
|
+
run the same hook while developing deadcode itself, use `make pre-commit`.
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
Create a feature branch from `main`, open a pull request targeting `main`, and
|
|
100
|
+
wait for review. Do not commit feature changes directly to `main`; release
|
|
101
|
+
commits are made by the maintainer on `main`.
|
|
102
|
+
|
|
52
103
|
## Command line options
|
|
53
104
|
|
|
54
105
|
| Option | Type | Meaning |
|
|
@@ -174,6 +225,11 @@ code base is implemented in.
|
|
|
174
225
|
- [ ] Investigate ways of extracting and backporting Python3.10+ `ast` implementation to lower Python versions.
|
|
175
226
|
|
|
176
227
|
## Release notes
|
|
228
|
+
- v2.5.0:
|
|
229
|
+
- Fix a crash when a decorator has no `id` attribute.
|
|
230
|
+
- v2.4.1:
|
|
231
|
+
- Add `--version` option to show `deadcode` version.
|
|
232
|
+
- Use stdout for `deadcode` output.
|
|
177
233
|
- v2.4.0:
|
|
178
234
|
- Add `--only` option that accepts filenames only which will be reflected in the output and modified.
|
|
179
235
|
This option can be used with `--fix` and `--fix --dry` options as well as for simple unused code detection without fixing.
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: deadcode
|
|
3
|
-
Version: 2.4.0
|
|
4
|
-
Summary: Find and remove dead code.
|
|
5
|
-
Project-URL: homepage, https://github.com/albertas/deadcode
|
|
6
|
-
Project-URL: documentation, https://deadcode.readthedocs.io/
|
|
7
|
-
Author-email: Albertas Gimbutas <albertasgim@gmail.com>
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Classifier: Development Status :: 3 - Alpha
|
|
10
|
-
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
11
|
-
Classifier: Natural Language :: English
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Requires-Python: >=3.10
|
|
18
|
-
Requires-Dist: tomli>=2.0.1
|
|
19
|
-
Provides-Extra: test
|
|
20
|
-
Requires-Dist: hatch; extra == 'test'
|
|
21
|
-
Requires-Dist: mypy; extra == 'test'
|
|
22
|
-
Requires-Dist: pip-audit; extra == 'test'
|
|
23
|
-
Requires-Dist: pytest; extra == 'test'
|
|
24
|
-
Requires-Dist: pytest-cov; extra == 'test'
|
|
25
|
-
Requires-Dist: ruff; extra == 'test'
|
|
26
|
-
Description-Content-Type: text/markdown
|
|
27
|
-
|
|
28
1
|
[](https://deadcode.readthedocs.io/en/stable/)
|
|
29
2
|
|
|
30
3
|
<h2 align="center">Find and Fix Unused Python Code</h2>
|
|
@@ -34,6 +7,7 @@ Description-Content-Type: text/markdown
|
|
|
34
7
|
<a href="https://pypi.org/project/deadcode/"><img alt="PyPI" src="https://img.shields.io/pypi/v/deadcode"></a>
|
|
35
8
|
<a href="https://pepy.tech/project/deadcode"><img alt="Downloads" src="https://static.pepy.tech/badge/deadcode"></a>
|
|
36
9
|
<a href="https://github.com/albertas/deadcode/blob/main/LICENSE"><img alt="License: AGPLv3" src="https://raw.githubusercontent.com/albertas/deadcode/main/docs/_static/AGPLv3-license.svg"></a>
|
|
10
|
+
<br/><a href='https://ko-fi.com/V7V21681GD' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi3.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
|
37
11
|
</p>
|
|
38
12
|
|
|
39
13
|
|
|
@@ -76,6 +50,28 @@ ignore-names = ["BaseTestCase", "*Mixin"]
|
|
|
76
50
|
ignore-names-in-files = ["migrations"]
|
|
77
51
|
```
|
|
78
52
|
|
|
53
|
+
## Pre-commit hook
|
|
54
|
+
Create a `.pre-commit-config.yaml` file in the root of your project directory, if it doesn't exist, and add the following to the file:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
# See https://pre-commit.com for more information
|
|
58
|
+
# See https://pre-commit.com/hooks.html for more hooks
|
|
59
|
+
repos:
|
|
60
|
+
- repo: https://github.com/albertas/deadcode
|
|
61
|
+
rev: 2.5.0
|
|
62
|
+
hooks:
|
|
63
|
+
- id: deadcode
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The `rev` is the release tag, so it matches the version published on PyPI. To
|
|
67
|
+
run the same hook while developing deadcode itself, use `make pre-commit`.
|
|
68
|
+
|
|
69
|
+
## Contributing
|
|
70
|
+
|
|
71
|
+
Create a feature branch from `main`, open a pull request targeting `main`, and
|
|
72
|
+
wait for review. Do not commit feature changes directly to `main`; release
|
|
73
|
+
commits are made by the maintainer on `main`.
|
|
74
|
+
|
|
79
75
|
## Command line options
|
|
80
76
|
|
|
81
77
|
| Option | Type | Meaning |
|
|
@@ -201,6 +197,11 @@ code base is implemented in.
|
|
|
201
197
|
- [ ] Investigate ways of extracting and backporting Python3.10+ `ast` implementation to lower Python versions.
|
|
202
198
|
|
|
203
199
|
## Release notes
|
|
200
|
+
- v2.5.0:
|
|
201
|
+
- Fix a crash when a decorator has no `id` attribute.
|
|
202
|
+
- v2.4.1:
|
|
203
|
+
- Add `--version` option to show `deadcode` version.
|
|
204
|
+
- Use stdout for `deadcode` output.
|
|
204
205
|
- v2.4.0:
|
|
205
206
|
- Add `--only` option that accepts filenames only which will be reflected in the output and modified.
|
|
206
207
|
This option can be used with `--fix` and `--fix --dry` options as well as for simple unused code detection without fixing.
|
|
@@ -194,6 +194,12 @@ def parse_arguments(args: Optional[List[str]]) -> Args:
|
|
|
194
194
|
action='store_true',
|
|
195
195
|
default=False,
|
|
196
196
|
)
|
|
197
|
+
parser.add_argument(
|
|
198
|
+
'--version',
|
|
199
|
+
help='Shows deadcode version',
|
|
200
|
+
action='store_true',
|
|
201
|
+
default=False,
|
|
202
|
+
)
|
|
197
203
|
|
|
198
204
|
parsed_args = parser.parse_args(args).__dict__
|
|
199
205
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from typing import List, Optional
|
|
2
|
+
import sys
|
|
2
3
|
|
|
4
|
+
from deadcode import __version__
|
|
3
5
|
from deadcode.actions.find_python_filenames import find_python_filenames
|
|
4
6
|
from deadcode.actions.find_unused_names import find_unused_names
|
|
5
7
|
from deadcode.actions.fix_or_show_unused_code import fix_or_show_unused_code
|
|
@@ -12,6 +14,9 @@ from deadcode.actions.get_unused_names_error_message import (
|
|
|
12
14
|
def main(
|
|
13
15
|
command_line_args: Optional[List[str]] = None,
|
|
14
16
|
) -> Optional[str]:
|
|
17
|
+
if command_line_args and '--version' in command_line_args or '--version' in sys.argv:
|
|
18
|
+
return __version__
|
|
19
|
+
|
|
15
20
|
args = parse_arguments(command_line_args)
|
|
16
21
|
|
|
17
22
|
filenames = find_python_filenames(args=args)
|
|
@@ -31,5 +36,10 @@ def main(
|
|
|
31
36
|
return None
|
|
32
37
|
|
|
33
38
|
|
|
39
|
+
def print_main() -> None:
|
|
40
|
+
if result := main():
|
|
41
|
+
print(result)
|
|
42
|
+
|
|
43
|
+
|
|
34
44
|
if __name__ == '__main__':
|
|
35
|
-
|
|
45
|
+
print_main()
|
|
@@ -58,7 +58,7 @@ def get_decorator_name(decorator: Union[ast.Call, ast.Attribute]) -> str:
|
|
|
58
58
|
while isinstance(decorator, ast.Attribute):
|
|
59
59
|
parts.append(decorator.attr)
|
|
60
60
|
decorator = decorator.value # type: ignore
|
|
61
|
-
|
|
61
|
+
parts.append(str(id(decorator)))
|
|
62
62
|
return '@' + '.'.join(reversed(parts))
|
|
63
63
|
|
|
64
64
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "deadcode"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.5.0"
|
|
4
4
|
authors = [
|
|
5
5
|
{name = "Albertas Gimbutas", email = "albertasgim@gmail.com"},
|
|
6
6
|
]
|
|
@@ -24,16 +24,17 @@ dependencies = [
|
|
|
24
24
|
[project.optional-dependencies]
|
|
25
25
|
test = [
|
|
26
26
|
"hatch",
|
|
27
|
-
"ruff",
|
|
28
|
-
"mypy",
|
|
27
|
+
"ruff==0.5.1",
|
|
28
|
+
"mypy==1.10.1",
|
|
29
29
|
"pip-audit",
|
|
30
30
|
"deadcode",
|
|
31
|
-
"
|
|
32
|
-
"pytest
|
|
31
|
+
"pre-commit",
|
|
32
|
+
"pytest==9.0.3",
|
|
33
|
+
"pytest-cov==5.0.0",
|
|
33
34
|
]
|
|
34
35
|
|
|
35
36
|
[project.scripts]
|
|
36
|
-
deadcode = "deadcode.cli:
|
|
37
|
+
deadcode = "deadcode.cli:print_main"
|
|
37
38
|
|
|
38
39
|
[project.urls]
|
|
39
40
|
homepage = "https://github.com/albertas/deadcode"
|
|
@@ -149,6 +150,7 @@ ignore = [
|
|
|
149
150
|
"tests/*" = [
|
|
150
151
|
"S101", # allow assert and no docs in tests
|
|
151
152
|
"PT009",
|
|
153
|
+
"PT027",
|
|
152
154
|
"ANN201",
|
|
153
155
|
"D",
|
|
154
156
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|