openrewrite-static-analysis 0.1.0.dev20260227145225__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.
- openrewrite_static_analysis-0.1.0.dev20260227145225/PKG-INFO +31 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/pyproject.toml +77 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/setup.cfg +4 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/__init__.py +35 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/__init__.py +14 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/boolean_simplification.py +819 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/collection_literals.py +319 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/comparison_simplification.py +333 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/complex_transforms.py +555 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/comprehension_cleanup.py +766 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/conditionals.py +915 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/datetime_cleanup.py +74 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/dict_cleanup.py +537 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/exception_cleanup.py +499 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/expression_simplification.py +434 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/loop_cleanup.py +420 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/naming_conventions.py +219 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/none_and_identity.py +265 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/pandas_cleanup.py +338 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/python_best_practices.py +256 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/range_cleanup.py +119 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/redundant_code.py +220 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/string_cleanup.py +885 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/syntax_cleanup.py +159 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/cleanup/unreachable_code.py +251 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis.egg-info/PKG-INFO +31 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis.egg-info/SOURCES.txt +49 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis.egg-info/dependency_links.txt +1 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis.egg-info/entry_points.txt +2 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis.egg-info/requires.txt +11 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis.egg-info/top_level.txt +1 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_boolean_simplification.py +687 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_collection_literals.py +234 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_comparison_simplification.py +166 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_complex_transforms.py +188 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_comprehension_cleanup.py +654 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_conditionals.py +544 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_datetime_cleanup.py +77 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_dict_cleanup.py +437 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_exception_cleanup.py +332 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_expression_simplification.py +167 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_loop_cleanup.py +270 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_naming_conventions.py +217 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_none_and_identity.py +264 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_pandas_cleanup.py +208 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_python_best_practices.py +101 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_range_cleanup.py +121 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_redundant_code.py +298 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_string_cleanup.py +362 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_syntax_cleanup.py +168 -0
- openrewrite_static_analysis-0.1.0.dev20260227145225/tests/test_unreachable_code.py +326 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openrewrite-static-analysis
|
|
3
|
+
Version: 0.1.0.dev20260227145225
|
|
4
|
+
Summary: OpenRewrite static analysis and code cleanup recipes for Python.
|
|
5
|
+
Author-email: "Moderne Inc." <support@moderne.io>
|
|
6
|
+
License: Moderne Proprietary
|
|
7
|
+
Project-URL: Homepage, https://github.com/moderneinc/rewrite-static-analysis
|
|
8
|
+
Project-URL: Repository, https://github.com/moderneinc/rewrite-static-analysis.git
|
|
9
|
+
Project-URL: Documentation, https://docs.openrewrite.org
|
|
10
|
+
Project-URL: Issues, https://github.com/moderneinc/rewrite-static-analysis/issues
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: Other/Proprietary License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: openrewrite>=8.74.0.dev20260224100132; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: black>=24.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
29
|
+
Provides-Extra: publish
|
|
30
|
+
Requires-Dist: build>=1.0.0; extra == "publish"
|
|
31
|
+
Requires-Dist: twine>=5.0.0; extra == "publish"
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "openrewrite-static-analysis"
|
|
7
|
+
description = "OpenRewrite static analysis and code cleanup recipes for Python."
|
|
8
|
+
version = "0.1.0.dev20260227145225" # Updated dynamically during release
|
|
9
|
+
authors = [{ name = "Moderne Inc.", email = "support@moderne.io" }]
|
|
10
|
+
license = { text = "Moderne Proprietary" }
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: Other/Proprietary License",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Topic :: Software Development :: Code Generators",
|
|
21
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
22
|
+
"Typing :: Typed",
|
|
23
|
+
]
|
|
24
|
+
requires-python = ">=3.10"
|
|
25
|
+
# openrewrite is a runtime dependency but is provided by the host
|
|
26
|
+
# environment (like a plugin framework). It is listed under
|
|
27
|
+
# [project.optional-dependencies] dev so it is available during
|
|
28
|
+
# development and testing without being pulled in again at install time.
|
|
29
|
+
dependencies = []
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"openrewrite>=8.74.0.dev20260224100132",
|
|
34
|
+
"pytest>=8.0.0",
|
|
35
|
+
"pytest-cov>=4.0.0",
|
|
36
|
+
"black>=24.0.0",
|
|
37
|
+
"ruff>=0.1.0",
|
|
38
|
+
]
|
|
39
|
+
publish = [
|
|
40
|
+
"build>=1.0.0",
|
|
41
|
+
"twine>=5.0.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/moderneinc/rewrite-static-analysis"
|
|
46
|
+
Repository = "https://github.com/moderneinc/rewrite-static-analysis.git"
|
|
47
|
+
Documentation = "https://docs.openrewrite.org"
|
|
48
|
+
Issues = "https://github.com/moderneinc/rewrite-static-analysis/issues"
|
|
49
|
+
|
|
50
|
+
[project.entry-points."openrewrite.recipes"]
|
|
51
|
+
static_analysis = "openrewrite_static_analysis:activate"
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
include = ["openrewrite_static_analysis", "openrewrite_static_analysis.*"]
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.package-data]
|
|
58
|
+
"*" = ["py.typed", "*.pyi"]
|
|
59
|
+
|
|
60
|
+
[tool.black]
|
|
61
|
+
line-length = 120
|
|
62
|
+
target-version = ["py310", "py311", "py312", "py313"]
|
|
63
|
+
|
|
64
|
+
[tool.ruff]
|
|
65
|
+
line-length = 120
|
|
66
|
+
target-version = "py310"
|
|
67
|
+
|
|
68
|
+
[tool.ruff.lint]
|
|
69
|
+
select = ["E", "F", "I", "UP"]
|
|
70
|
+
|
|
71
|
+
[tool.uv]
|
|
72
|
+
prerelease = "allow"
|
|
73
|
+
|
|
74
|
+
[tool.pytest.ini_options]
|
|
75
|
+
testpaths = ["tests"]
|
|
76
|
+
python_files = ["test_*.py", "*_test.py"]
|
|
77
|
+
python_functions = ["test_*"]
|
openrewrite_static_analysis-0.1.0.dev20260227145225/src/openrewrite_static_analysis/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""OpenRewrite static analysis and code cleanup recipes for Python."""
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import inspect
|
|
5
|
+
import pkgutil
|
|
6
|
+
|
|
7
|
+
from rewrite import Recipe, RecipeMarketplace
|
|
8
|
+
|
|
9
|
+
__all__ = ["activate"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def activate(marketplace: RecipeMarketplace) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Install all static analysis recipes into the marketplace.
|
|
15
|
+
|
|
16
|
+
This function is called by the OpenRewrite discovery mechanism when the
|
|
17
|
+
openrewrite-static-analysis package is found via entry points.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
marketplace: The RecipeMarketplace to install recipes into
|
|
21
|
+
"""
|
|
22
|
+
from rewrite.decorators import get_recipe_category
|
|
23
|
+
|
|
24
|
+
from . import cleanup as cleanup_pkg
|
|
25
|
+
|
|
26
|
+
# Auto-discover all Recipe subclasses from the cleanup package
|
|
27
|
+
for module_info in pkgutil.walk_packages(
|
|
28
|
+
cleanup_pkg.__path__, prefix=cleanup_pkg.__name__ + "."
|
|
29
|
+
):
|
|
30
|
+
module = importlib.import_module(module_info.name)
|
|
31
|
+
for _name, obj in inspect.getmembers(module, inspect.isclass):
|
|
32
|
+
if issubclass(obj, Recipe) and obj is not Recipe and obj.__module__ == module.__name__:
|
|
33
|
+
category = get_recipe_category(obj)
|
|
34
|
+
if category is not None:
|
|
35
|
+
marketplace.install(obj, category)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""OpenRewrite recipes for Python code quality and cleanup."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from rewrite.java import J
|
|
6
|
+
from rewrite.python.template.comparator import PatternMatchingComparator
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from rewrite.visitor import Cursor
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def trees_equal(a: J, b: J, cursor: "Cursor") -> bool:
|
|
13
|
+
"""Check if two AST subtrees are structurally equal, ignoring whitespace."""
|
|
14
|
+
return PatternMatchingComparator(captures={}).match(a, b, cursor) is not None
|