pyrefactor 1.0.3__tar.gz → 1.0.4__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.
- pyrefactor-1.0.4/PKG-INFO +215 -0
- pyrefactor-1.0.4/README.md +172 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/__init__.py +1 -1
- pyrefactor-1.0.4/src/pyrefactor.egg-info/PKG-INFO +215 -0
- pyrefactor-1.0.3/PKG-INFO +0 -353
- pyrefactor-1.0.3/README.md +0 -310
- pyrefactor-1.0.3/src/pyrefactor.egg-info/PKG-INFO +0 -353
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/LICENSE.md +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/pyproject.toml +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/setup.cfg +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/__main__.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/analyzer.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/ast_visitor.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/config.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/__init__.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/boolean_logic.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/comparisons.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/complexity.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/context_manager.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/control_flow.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/dict_operations.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/duplication.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/loops.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/detectors/performance.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/models.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/py.typed +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor/reporter.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor.egg-info/SOURCES.txt +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor.egg-info/dependency_links.txt +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor.egg-info/entry_points.txt +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor.egg-info/requires.txt +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/src/pyrefactor.egg-info/top_level.txt +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_analyzer.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_boolean_logic_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_cli.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_comparisons_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_complexity_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_config.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_context_manager_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_control_flow_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_dict_operations_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_duplication_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_hypothesis_analyzer.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_hypothesis_ast_visitor.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_hypothesis_config.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_hypothesis_models.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_hypothesis_reporter.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_integration.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_loops_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_models.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_performance_detector.py +0 -0
- {pyrefactor-1.0.3 → pyrefactor-1.0.4}/tests/test_reporter.py +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrefactor
|
|
3
|
+
Version: 1.0.4
|
|
4
|
+
Summary: A Python refactoring and optimization linter that analyzes code for performance issues, complexity problems, and opportunities for improvement
|
|
5
|
+
Author: tboy1337
|
|
6
|
+
Maintainer: tboy1337
|
|
7
|
+
License: Commercial Restricted License (CRL)
|
|
8
|
+
Project-URL: Homepage, https://github.com/tboy1337/PyRefactor
|
|
9
|
+
Project-URL: Repository, https://github.com/tboy1337/PyRefactor
|
|
10
|
+
Project-URL: Issues, https://github.com/tboy1337/PyRefactor/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/tboy1337/PyRefactor/releases
|
|
12
|
+
Project-URL: Documentation, https://github.com/tboy1337/PyRefactor#readme
|
|
13
|
+
Keywords: refactoring,linter,code-quality,static-analysis,ast,optimization,performance,complexity,code-analysis,python-linter,code-smell,maintainability,best-practices,code-review,cyclomatic-complexity
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: Other/Proprietary License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Programming Language :: Python
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
29
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
30
|
+
Classifier: Topic :: Software Development
|
|
31
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
32
|
+
Classifier: Topic :: Software Development :: Testing
|
|
33
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
34
|
+
Classifier: Topic :: Utilities
|
|
35
|
+
Classifier: Typing :: Typed
|
|
36
|
+
Classifier: Environment :: Console
|
|
37
|
+
Classifier: Natural Language :: English
|
|
38
|
+
Requires-Python: >=3.9
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE.md
|
|
41
|
+
Requires-Dist: colorama
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# PyRefactor
|
|
45
|
+
|
|
46
|
+
A Python refactoring and optimization linter that uses AST analysis to identify performance issues, complexity problems, and code improvements.
|
|
47
|
+
|
|
48
|
+
[](https://www.python.org/downloads/)
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Multi-threaded Analysis**: Fast parallel file processing
|
|
53
|
+
- **Configurable Detectors**: Enable/disable specific detectors
|
|
54
|
+
- **Severity Levels**: Issues categorized as INFO, LOW, MEDIUM, or HIGH
|
|
55
|
+
- **Flexible Output**: Group by file or severity
|
|
56
|
+
- **Cross-platform**: Works on Windows, macOS, and Linux
|
|
57
|
+
|
|
58
|
+
## Detectors
|
|
59
|
+
|
|
60
|
+
- **Complexity**: High cyclomatic complexity functions
|
|
61
|
+
- **Performance**: String concatenation in loops, uncached calls, inefficient operations
|
|
62
|
+
- **Boolean Logic**: Overcomplicated boolean expressions
|
|
63
|
+
- **Loops**: Nested loops, invariant code, comprehension opportunities
|
|
64
|
+
- **Duplication**: Duplicate code blocks
|
|
65
|
+
- **Context Manager**: Missing `with` statements for resource operations
|
|
66
|
+
- **Control Flow**: Unnecessary `else` after `return`/`raise`/`break`/`continue`
|
|
67
|
+
- **Dictionary Operations**: Non-idiomatic dict patterns, missing `.get()`, unnecessary `.keys()`
|
|
68
|
+
- **Comparisons**: Chained comparisons, singleton checks, `type()` vs `isinstance()`
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
### Recommended: Via pip
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install pyrefactor
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Standalone Executable
|
|
79
|
+
|
|
80
|
+
Download the latest release from the [Releases](https://github.com/tboy1337/PyRefactor/releases/latest) section. No Python installation required.
|
|
81
|
+
|
|
82
|
+
### From Source
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/tboy1337/PyRefactor.git
|
|
86
|
+
cd PyRefactor
|
|
87
|
+
pip install -e .
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Requirements**: Python 3.9+
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Analyze a file or directory
|
|
96
|
+
pyrefactor myfile.py
|
|
97
|
+
pyrefactor src/
|
|
98
|
+
|
|
99
|
+
# Show only medium/high severity issues
|
|
100
|
+
pyrefactor --min-severity medium src/
|
|
101
|
+
|
|
102
|
+
# Group by severity level
|
|
103
|
+
pyrefactor --group-by severity src/
|
|
104
|
+
|
|
105
|
+
# Use more workers for faster analysis
|
|
106
|
+
pyrefactor --jobs 8 src/
|
|
107
|
+
|
|
108
|
+
# Custom configuration file
|
|
109
|
+
pyrefactor --config custom.toml src/
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Options
|
|
113
|
+
|
|
114
|
+
- `-c, --config`: Configuration file path (default: `pyproject.toml`)
|
|
115
|
+
- `-g, --group-by`: Group by `file` or `severity` (default: `file`)
|
|
116
|
+
- `--min-severity`: Minimum severity to report: `info`, `low`, `medium`, `high` (default: `info`)
|
|
117
|
+
- `-j, --jobs`: Number of parallel workers (default: 4)
|
|
118
|
+
- `-v, --verbose`: Enable verbose logging
|
|
119
|
+
- `--version`: Show version
|
|
120
|
+
|
|
121
|
+
### Exit Codes
|
|
122
|
+
|
|
123
|
+
- `0` - No issues or only INFO/LOW severity
|
|
124
|
+
- `1` - MEDIUM/HIGH severity issues found
|
|
125
|
+
- `2` - Analysis error (syntax errors, invalid paths)
|
|
126
|
+
|
|
127
|
+
## Configuration
|
|
128
|
+
|
|
129
|
+
Configure via TOML file (e.g., `pyproject.toml`):
|
|
130
|
+
|
|
131
|
+
```toml
|
|
132
|
+
[tool.pyrefactor]
|
|
133
|
+
exclude_patterns = ["__pycache__", ".venv", "build", "dist"]
|
|
134
|
+
|
|
135
|
+
[tool.pyrefactor.complexity]
|
|
136
|
+
max_complexity = 10
|
|
137
|
+
|
|
138
|
+
[tool.pyrefactor.performance]
|
|
139
|
+
enabled = true
|
|
140
|
+
min_concatenations = 3
|
|
141
|
+
min_duplicate_calls = 3
|
|
142
|
+
|
|
143
|
+
[tool.pyrefactor.boolean_logic]
|
|
144
|
+
enabled = true
|
|
145
|
+
min_depth = 3
|
|
146
|
+
|
|
147
|
+
[tool.pyrefactor.loops]
|
|
148
|
+
enabled = true
|
|
149
|
+
max_nesting = 3
|
|
150
|
+
|
|
151
|
+
[tool.pyrefactor.duplication]
|
|
152
|
+
enabled = true
|
|
153
|
+
min_lines = 5
|
|
154
|
+
similarity_threshold = 0.8
|
|
155
|
+
|
|
156
|
+
[tool.pyrefactor.context_manager]
|
|
157
|
+
enabled = true
|
|
158
|
+
|
|
159
|
+
[tool.pyrefactor.control_flow]
|
|
160
|
+
enabled = true
|
|
161
|
+
|
|
162
|
+
[tool.pyrefactor.dict_operations]
|
|
163
|
+
enabled = true
|
|
164
|
+
|
|
165
|
+
[tool.pyrefactor.comparisons]
|
|
166
|
+
enabled = true
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Configuration is searched in: `--config` → `pyproject.toml` → `pyrefactor.ini` → defaults
|
|
170
|
+
|
|
171
|
+
## CI/CD Integration
|
|
172
|
+
|
|
173
|
+
### Pre-commit Hook
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
repos:
|
|
177
|
+
- repo: local
|
|
178
|
+
hooks:
|
|
179
|
+
- id: pyrefactor
|
|
180
|
+
name: PyRefactor
|
|
181
|
+
entry: pyrefactor
|
|
182
|
+
language: system
|
|
183
|
+
types: [python]
|
|
184
|
+
args: [--min-severity=medium]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### GitHub Actions
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
name: Code Quality
|
|
191
|
+
on: [push, pull_request]
|
|
192
|
+
|
|
193
|
+
jobs:
|
|
194
|
+
pyrefactor:
|
|
195
|
+
runs-on: ubuntu-latest
|
|
196
|
+
steps:
|
|
197
|
+
- uses: actions/checkout@v3
|
|
198
|
+
- uses: actions/setup-python@v4
|
|
199
|
+
with:
|
|
200
|
+
python-version: '3.9'
|
|
201
|
+
- run: pip install pyrefactor
|
|
202
|
+
- run: pyrefactor --min-severity medium src/
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
Contributions are welcome! This project is under a Commercial Restricted License (CRL). For commercial use, contact the copyright holder.
|
|
208
|
+
|
|
209
|
+
1. Follow existing code style (Black, isort)
|
|
210
|
+
2. Add tests for new features (>95% coverage)
|
|
211
|
+
3. Run type checking and linting
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
Licensed under the CRL license - see [LICENSE.md](LICENSE.md) for details.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# PyRefactor
|
|
2
|
+
|
|
3
|
+
A Python refactoring and optimization linter that uses AST analysis to identify performance issues, complexity problems, and code improvements.
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Multi-threaded Analysis**: Fast parallel file processing
|
|
10
|
+
- **Configurable Detectors**: Enable/disable specific detectors
|
|
11
|
+
- **Severity Levels**: Issues categorized as INFO, LOW, MEDIUM, or HIGH
|
|
12
|
+
- **Flexible Output**: Group by file or severity
|
|
13
|
+
- **Cross-platform**: Works on Windows, macOS, and Linux
|
|
14
|
+
|
|
15
|
+
## Detectors
|
|
16
|
+
|
|
17
|
+
- **Complexity**: High cyclomatic complexity functions
|
|
18
|
+
- **Performance**: String concatenation in loops, uncached calls, inefficient operations
|
|
19
|
+
- **Boolean Logic**: Overcomplicated boolean expressions
|
|
20
|
+
- **Loops**: Nested loops, invariant code, comprehension opportunities
|
|
21
|
+
- **Duplication**: Duplicate code blocks
|
|
22
|
+
- **Context Manager**: Missing `with` statements for resource operations
|
|
23
|
+
- **Control Flow**: Unnecessary `else` after `return`/`raise`/`break`/`continue`
|
|
24
|
+
- **Dictionary Operations**: Non-idiomatic dict patterns, missing `.get()`, unnecessary `.keys()`
|
|
25
|
+
- **Comparisons**: Chained comparisons, singleton checks, `type()` vs `isinstance()`
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
### Recommended: Via pip
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install pyrefactor
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Standalone Executable
|
|
36
|
+
|
|
37
|
+
Download the latest release from the [Releases](https://github.com/tboy1337/PyRefactor/releases/latest) section. No Python installation required.
|
|
38
|
+
|
|
39
|
+
### From Source
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/tboy1337/PyRefactor.git
|
|
43
|
+
cd PyRefactor
|
|
44
|
+
pip install -e .
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Requirements**: Python 3.9+
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Analyze a file or directory
|
|
53
|
+
pyrefactor myfile.py
|
|
54
|
+
pyrefactor src/
|
|
55
|
+
|
|
56
|
+
# Show only medium/high severity issues
|
|
57
|
+
pyrefactor --min-severity medium src/
|
|
58
|
+
|
|
59
|
+
# Group by severity level
|
|
60
|
+
pyrefactor --group-by severity src/
|
|
61
|
+
|
|
62
|
+
# Use more workers for faster analysis
|
|
63
|
+
pyrefactor --jobs 8 src/
|
|
64
|
+
|
|
65
|
+
# Custom configuration file
|
|
66
|
+
pyrefactor --config custom.toml src/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Options
|
|
70
|
+
|
|
71
|
+
- `-c, --config`: Configuration file path (default: `pyproject.toml`)
|
|
72
|
+
- `-g, --group-by`: Group by `file` or `severity` (default: `file`)
|
|
73
|
+
- `--min-severity`: Minimum severity to report: `info`, `low`, `medium`, `high` (default: `info`)
|
|
74
|
+
- `-j, --jobs`: Number of parallel workers (default: 4)
|
|
75
|
+
- `-v, --verbose`: Enable verbose logging
|
|
76
|
+
- `--version`: Show version
|
|
77
|
+
|
|
78
|
+
### Exit Codes
|
|
79
|
+
|
|
80
|
+
- `0` - No issues or only INFO/LOW severity
|
|
81
|
+
- `1` - MEDIUM/HIGH severity issues found
|
|
82
|
+
- `2` - Analysis error (syntax errors, invalid paths)
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
Configure via TOML file (e.g., `pyproject.toml`):
|
|
87
|
+
|
|
88
|
+
```toml
|
|
89
|
+
[tool.pyrefactor]
|
|
90
|
+
exclude_patterns = ["__pycache__", ".venv", "build", "dist"]
|
|
91
|
+
|
|
92
|
+
[tool.pyrefactor.complexity]
|
|
93
|
+
max_complexity = 10
|
|
94
|
+
|
|
95
|
+
[tool.pyrefactor.performance]
|
|
96
|
+
enabled = true
|
|
97
|
+
min_concatenations = 3
|
|
98
|
+
min_duplicate_calls = 3
|
|
99
|
+
|
|
100
|
+
[tool.pyrefactor.boolean_logic]
|
|
101
|
+
enabled = true
|
|
102
|
+
min_depth = 3
|
|
103
|
+
|
|
104
|
+
[tool.pyrefactor.loops]
|
|
105
|
+
enabled = true
|
|
106
|
+
max_nesting = 3
|
|
107
|
+
|
|
108
|
+
[tool.pyrefactor.duplication]
|
|
109
|
+
enabled = true
|
|
110
|
+
min_lines = 5
|
|
111
|
+
similarity_threshold = 0.8
|
|
112
|
+
|
|
113
|
+
[tool.pyrefactor.context_manager]
|
|
114
|
+
enabled = true
|
|
115
|
+
|
|
116
|
+
[tool.pyrefactor.control_flow]
|
|
117
|
+
enabled = true
|
|
118
|
+
|
|
119
|
+
[tool.pyrefactor.dict_operations]
|
|
120
|
+
enabled = true
|
|
121
|
+
|
|
122
|
+
[tool.pyrefactor.comparisons]
|
|
123
|
+
enabled = true
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Configuration is searched in: `--config` → `pyproject.toml` → `pyrefactor.ini` → defaults
|
|
127
|
+
|
|
128
|
+
## CI/CD Integration
|
|
129
|
+
|
|
130
|
+
### Pre-commit Hook
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
repos:
|
|
134
|
+
- repo: local
|
|
135
|
+
hooks:
|
|
136
|
+
- id: pyrefactor
|
|
137
|
+
name: PyRefactor
|
|
138
|
+
entry: pyrefactor
|
|
139
|
+
language: system
|
|
140
|
+
types: [python]
|
|
141
|
+
args: [--min-severity=medium]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### GitHub Actions
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
name: Code Quality
|
|
148
|
+
on: [push, pull_request]
|
|
149
|
+
|
|
150
|
+
jobs:
|
|
151
|
+
pyrefactor:
|
|
152
|
+
runs-on: ubuntu-latest
|
|
153
|
+
steps:
|
|
154
|
+
- uses: actions/checkout@v3
|
|
155
|
+
- uses: actions/setup-python@v4
|
|
156
|
+
with:
|
|
157
|
+
python-version: '3.9'
|
|
158
|
+
- run: pip install pyrefactor
|
|
159
|
+
- run: pyrefactor --min-severity medium src/
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
Contributions are welcome! This project is under a Commercial Restricted License (CRL). For commercial use, contact the copyright holder.
|
|
165
|
+
|
|
166
|
+
1. Follow existing code style (Black, isort)
|
|
167
|
+
2. Add tests for new features (>95% coverage)
|
|
168
|
+
3. Run type checking and linting
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
Licensed under the CRL license - see [LICENSE.md](LICENSE.md) for details.
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyrefactor
|
|
3
|
+
Version: 1.0.4
|
|
4
|
+
Summary: A Python refactoring and optimization linter that analyzes code for performance issues, complexity problems, and opportunities for improvement
|
|
5
|
+
Author: tboy1337
|
|
6
|
+
Maintainer: tboy1337
|
|
7
|
+
License: Commercial Restricted License (CRL)
|
|
8
|
+
Project-URL: Homepage, https://github.com/tboy1337/PyRefactor
|
|
9
|
+
Project-URL: Repository, https://github.com/tboy1337/PyRefactor
|
|
10
|
+
Project-URL: Issues, https://github.com/tboy1337/PyRefactor/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/tboy1337/PyRefactor/releases
|
|
12
|
+
Project-URL: Documentation, https://github.com/tboy1337/PyRefactor#readme
|
|
13
|
+
Keywords: refactoring,linter,code-quality,static-analysis,ast,optimization,performance,complexity,code-analysis,python-linter,code-smell,maintainability,best-practices,code-review,cyclomatic-complexity
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: Other/Proprietary License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Programming Language :: Python
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
28
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
29
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
30
|
+
Classifier: Topic :: Software Development
|
|
31
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
32
|
+
Classifier: Topic :: Software Development :: Testing
|
|
33
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
34
|
+
Classifier: Topic :: Utilities
|
|
35
|
+
Classifier: Typing :: Typed
|
|
36
|
+
Classifier: Environment :: Console
|
|
37
|
+
Classifier: Natural Language :: English
|
|
38
|
+
Requires-Python: >=3.9
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE.md
|
|
41
|
+
Requires-Dist: colorama
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# PyRefactor
|
|
45
|
+
|
|
46
|
+
A Python refactoring and optimization linter that uses AST analysis to identify performance issues, complexity problems, and code improvements.
|
|
47
|
+
|
|
48
|
+
[](https://www.python.org/downloads/)
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Multi-threaded Analysis**: Fast parallel file processing
|
|
53
|
+
- **Configurable Detectors**: Enable/disable specific detectors
|
|
54
|
+
- **Severity Levels**: Issues categorized as INFO, LOW, MEDIUM, or HIGH
|
|
55
|
+
- **Flexible Output**: Group by file or severity
|
|
56
|
+
- **Cross-platform**: Works on Windows, macOS, and Linux
|
|
57
|
+
|
|
58
|
+
## Detectors
|
|
59
|
+
|
|
60
|
+
- **Complexity**: High cyclomatic complexity functions
|
|
61
|
+
- **Performance**: String concatenation in loops, uncached calls, inefficient operations
|
|
62
|
+
- **Boolean Logic**: Overcomplicated boolean expressions
|
|
63
|
+
- **Loops**: Nested loops, invariant code, comprehension opportunities
|
|
64
|
+
- **Duplication**: Duplicate code blocks
|
|
65
|
+
- **Context Manager**: Missing `with` statements for resource operations
|
|
66
|
+
- **Control Flow**: Unnecessary `else` after `return`/`raise`/`break`/`continue`
|
|
67
|
+
- **Dictionary Operations**: Non-idiomatic dict patterns, missing `.get()`, unnecessary `.keys()`
|
|
68
|
+
- **Comparisons**: Chained comparisons, singleton checks, `type()` vs `isinstance()`
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
### Recommended: Via pip
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install pyrefactor
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Standalone Executable
|
|
79
|
+
|
|
80
|
+
Download the latest release from the [Releases](https://github.com/tboy1337/PyRefactor/releases/latest) section. No Python installation required.
|
|
81
|
+
|
|
82
|
+
### From Source
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/tboy1337/PyRefactor.git
|
|
86
|
+
cd PyRefactor
|
|
87
|
+
pip install -e .
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Requirements**: Python 3.9+
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Analyze a file or directory
|
|
96
|
+
pyrefactor myfile.py
|
|
97
|
+
pyrefactor src/
|
|
98
|
+
|
|
99
|
+
# Show only medium/high severity issues
|
|
100
|
+
pyrefactor --min-severity medium src/
|
|
101
|
+
|
|
102
|
+
# Group by severity level
|
|
103
|
+
pyrefactor --group-by severity src/
|
|
104
|
+
|
|
105
|
+
# Use more workers for faster analysis
|
|
106
|
+
pyrefactor --jobs 8 src/
|
|
107
|
+
|
|
108
|
+
# Custom configuration file
|
|
109
|
+
pyrefactor --config custom.toml src/
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Options
|
|
113
|
+
|
|
114
|
+
- `-c, --config`: Configuration file path (default: `pyproject.toml`)
|
|
115
|
+
- `-g, --group-by`: Group by `file` or `severity` (default: `file`)
|
|
116
|
+
- `--min-severity`: Minimum severity to report: `info`, `low`, `medium`, `high` (default: `info`)
|
|
117
|
+
- `-j, --jobs`: Number of parallel workers (default: 4)
|
|
118
|
+
- `-v, --verbose`: Enable verbose logging
|
|
119
|
+
- `--version`: Show version
|
|
120
|
+
|
|
121
|
+
### Exit Codes
|
|
122
|
+
|
|
123
|
+
- `0` - No issues or only INFO/LOW severity
|
|
124
|
+
- `1` - MEDIUM/HIGH severity issues found
|
|
125
|
+
- `2` - Analysis error (syntax errors, invalid paths)
|
|
126
|
+
|
|
127
|
+
## Configuration
|
|
128
|
+
|
|
129
|
+
Configure via TOML file (e.g., `pyproject.toml`):
|
|
130
|
+
|
|
131
|
+
```toml
|
|
132
|
+
[tool.pyrefactor]
|
|
133
|
+
exclude_patterns = ["__pycache__", ".venv", "build", "dist"]
|
|
134
|
+
|
|
135
|
+
[tool.pyrefactor.complexity]
|
|
136
|
+
max_complexity = 10
|
|
137
|
+
|
|
138
|
+
[tool.pyrefactor.performance]
|
|
139
|
+
enabled = true
|
|
140
|
+
min_concatenations = 3
|
|
141
|
+
min_duplicate_calls = 3
|
|
142
|
+
|
|
143
|
+
[tool.pyrefactor.boolean_logic]
|
|
144
|
+
enabled = true
|
|
145
|
+
min_depth = 3
|
|
146
|
+
|
|
147
|
+
[tool.pyrefactor.loops]
|
|
148
|
+
enabled = true
|
|
149
|
+
max_nesting = 3
|
|
150
|
+
|
|
151
|
+
[tool.pyrefactor.duplication]
|
|
152
|
+
enabled = true
|
|
153
|
+
min_lines = 5
|
|
154
|
+
similarity_threshold = 0.8
|
|
155
|
+
|
|
156
|
+
[tool.pyrefactor.context_manager]
|
|
157
|
+
enabled = true
|
|
158
|
+
|
|
159
|
+
[tool.pyrefactor.control_flow]
|
|
160
|
+
enabled = true
|
|
161
|
+
|
|
162
|
+
[tool.pyrefactor.dict_operations]
|
|
163
|
+
enabled = true
|
|
164
|
+
|
|
165
|
+
[tool.pyrefactor.comparisons]
|
|
166
|
+
enabled = true
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Configuration is searched in: `--config` → `pyproject.toml` → `pyrefactor.ini` → defaults
|
|
170
|
+
|
|
171
|
+
## CI/CD Integration
|
|
172
|
+
|
|
173
|
+
### Pre-commit Hook
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
repos:
|
|
177
|
+
- repo: local
|
|
178
|
+
hooks:
|
|
179
|
+
- id: pyrefactor
|
|
180
|
+
name: PyRefactor
|
|
181
|
+
entry: pyrefactor
|
|
182
|
+
language: system
|
|
183
|
+
types: [python]
|
|
184
|
+
args: [--min-severity=medium]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### GitHub Actions
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
name: Code Quality
|
|
191
|
+
on: [push, pull_request]
|
|
192
|
+
|
|
193
|
+
jobs:
|
|
194
|
+
pyrefactor:
|
|
195
|
+
runs-on: ubuntu-latest
|
|
196
|
+
steps:
|
|
197
|
+
- uses: actions/checkout@v3
|
|
198
|
+
- uses: actions/setup-python@v4
|
|
199
|
+
with:
|
|
200
|
+
python-version: '3.9'
|
|
201
|
+
- run: pip install pyrefactor
|
|
202
|
+
- run: pyrefactor --min-severity medium src/
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
Contributions are welcome! This project is under a Commercial Restricted License (CRL). For commercial use, contact the copyright holder.
|
|
208
|
+
|
|
209
|
+
1. Follow existing code style (Black, isort)
|
|
210
|
+
2. Add tests for new features (>95% coverage)
|
|
211
|
+
3. Run type checking and linting
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
Licensed under the CRL license - see [LICENSE.md](LICENSE.md) for details.
|