python-utility-scripts 1.0.16__tar.gz → 1.0.17__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.
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/PKG-INFO +2 -1
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/unused_code/README.md +15 -3
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/unused_code/unused_code.py +7 -2
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/pyproject.toml +3 -2
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/.gitignore +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/LICENSE +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/README.md +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/__init__.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/jira_utils/README.md +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/jira_utils/__init__.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/jira_utils/jira_information.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/polarion/README.md +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/polarion/__init__.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/polarion/polarion_set_automated.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/polarion/polarion_utils.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/polarion/polarion_verify_tc_requirements.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/unused_code/__init__.py +0 -0
- {python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-utility-scripts
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.17
|
|
4
4
|
Summary: Python utility scripts
|
|
5
5
|
Project-URL: Homepage, https://github.com/RedHatQE/python-utility-scripts
|
|
6
6
|
Project-URL: Repository, https://github.com/RedHatQE/python-utility-scripts
|
|
@@ -11,6 +11,7 @@ License-File: LICENSE
|
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Requires-Python: ~=3.9
|
|
14
|
+
Requires-Dist: ast-comments>=1.2.2
|
|
14
15
|
Requires-Dist: jira<4,>=3.6.0
|
|
15
16
|
Requires-Dist: pyhelper-utils<2,>=1.0.1
|
|
16
17
|
Requires-Dist: pylero<0.2,>=0.1.0
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# pyutils-unusedcode
|
|
2
|
+
|
|
2
3
|
Helper to identify unused code in a pytest repository. It should be run from inside the test repository using this tool.
|
|
3
4
|
|
|
4
5
|
## Usage
|
|
@@ -9,18 +10,20 @@ pyutils-unusedcode --help
|
|
|
9
10
|
```
|
|
10
11
|
|
|
11
12
|
## Config file
|
|
13
|
+
|
|
12
14
|
To skip unused code check on specific files or functions of a repository, a config file with the list of names of such files and function prefixes should be added to
|
|
13
15
|
`~/.config/python-utility-scripts/config.yaml`
|
|
14
16
|
|
|
15
|
-
### Example
|
|
17
|
+
### Example
|
|
16
18
|
|
|
17
19
|
```yaml
|
|
18
20
|
pyutils-unusedcode:
|
|
19
21
|
exclude_files:
|
|
20
|
-
|
|
22
|
+
- "my_exclude_file.py"
|
|
21
23
|
exclude_function_prefix:
|
|
22
|
-
|
|
24
|
+
- "my_exclude_function_prefix"
|
|
23
25
|
```
|
|
26
|
+
|
|
24
27
|
This would exclude any functions with prefix my_exclude_function_prefix and file my_exclude_file.py from unused code check
|
|
25
28
|
|
|
26
29
|
To run from CLI with `--exclude-function-prefixes`
|
|
@@ -34,3 +37,12 @@ To run from CLI with `--exclude-files`
|
|
|
34
37
|
```bash
|
|
35
38
|
pyutils-unusedcode --exclude-files 'my_exclude_file1.py,my_exclude_file2.py'
|
|
36
39
|
```
|
|
40
|
+
|
|
41
|
+
### Skip single function in file
|
|
42
|
+
|
|
43
|
+
Add `# skip-unused-code` comment in the function name list to skip it from check.
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
def my_function(): # skip-unused-code
|
|
47
|
+
pass
|
|
48
|
+
```
|
{python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/unused_code/unused_code.py
RENAMED
|
@@ -9,6 +9,7 @@ from concurrent.futures import Future, ThreadPoolExecutor, as_completed
|
|
|
9
9
|
from typing import Any, Iterable
|
|
10
10
|
|
|
11
11
|
import click
|
|
12
|
+
from ast_comments import parse
|
|
12
13
|
from simple_logger.logger import get_logger
|
|
13
14
|
|
|
14
15
|
from apps.utils import ListParamType, all_python_files, get_util_config
|
|
@@ -58,7 +59,7 @@ def process_file(py_file: str, func_ignore_prefix: list[str], file_ignore_list:
|
|
|
58
59
|
return ""
|
|
59
60
|
|
|
60
61
|
with open(py_file) as fd:
|
|
61
|
-
tree =
|
|
62
|
+
tree = parse(source=fd.read())
|
|
62
63
|
|
|
63
64
|
for func in _iter_functions(tree=tree):
|
|
64
65
|
if func_ignore_prefix and is_ignore_function_list(ignore_prefix_list=func_ignore_prefix, function=func):
|
|
@@ -69,8 +70,12 @@ def process_file(py_file: str, func_ignore_prefix: list[str], file_ignore_list:
|
|
|
69
70
|
LOGGER.debug(f"Skipping `autouse` fixture function: {func.name}")
|
|
70
71
|
continue
|
|
71
72
|
|
|
73
|
+
if any(getattr(item, "value", None) == "# skip-unused-code" for item in func.body):
|
|
74
|
+
LOGGER.debug(f"Skipping function {func.name}: found `# skip-unused-code`")
|
|
75
|
+
continue
|
|
76
|
+
|
|
72
77
|
used = False
|
|
73
|
-
_func_grep_found = subprocess.check_output(["git", "grep", "-
|
|
78
|
+
_func_grep_found = subprocess.check_output(["git", "grep", "-wE", f"{func.name}(.*)"], shell=False)
|
|
74
79
|
|
|
75
80
|
for entry in _func_grep_found.decode().splitlines():
|
|
76
81
|
_, _line = entry.split(":", 1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-utility-scripts"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.17"
|
|
4
4
|
description = "Python utility scripts"
|
|
5
5
|
requires-python = "~=3.9"
|
|
6
6
|
readme = "README.md"
|
|
@@ -16,7 +16,8 @@ dependencies = [
|
|
|
16
16
|
"jira>=3.6.0,<4",
|
|
17
17
|
"tenacity>=9.0.0,<10",
|
|
18
18
|
"python-simple-logger>=2.0.0,<3",
|
|
19
|
-
"pyhelper-utils>=1.0.1,<2"
|
|
19
|
+
"pyhelper-utils>=1.0.1,<2",
|
|
20
|
+
"ast-comments>=1.2.2"
|
|
20
21
|
]
|
|
21
22
|
|
|
22
23
|
[[project.authors]]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/jira_utils/jira_information.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/polarion/polarion_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_utility_scripts-1.0.16 → python_utility_scripts-1.0.17}/apps/unused_code/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|