openrewrite 8.73.0.dev20260131161045__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.

Potentially problematic release.


This version of openrewrite might be problematic. Click here for more details.

Files changed (68) hide show
  1. openrewrite-8.73.0.dev20260131161045/PKG-INFO +105 -0
  2. openrewrite-8.73.0.dev20260131161045/README.md +72 -0
  3. openrewrite-8.73.0.dev20260131161045/pyproject.toml +88 -0
  4. openrewrite-8.73.0.dev20260131161045/setup.cfg +4 -0
  5. openrewrite-8.73.0.dev20260131161045/src/openrewrite.egg-info/PKG-INFO +105 -0
  6. openrewrite-8.73.0.dev20260131161045/src/openrewrite.egg-info/SOURCES.txt +66 -0
  7. openrewrite-8.73.0.dev20260131161045/src/openrewrite.egg-info/dependency_links.txt +1 -0
  8. openrewrite-8.73.0.dev20260131161045/src/openrewrite.egg-info/entry_points.txt +2 -0
  9. openrewrite-8.73.0.dev20260131161045/src/openrewrite.egg-info/requires.txt +14 -0
  10. openrewrite-8.73.0.dev20260131161045/src/openrewrite.egg-info/top_level.txt +1 -0
  11. openrewrite-8.73.0.dev20260131161045/src/rewrite/__init__.py +111 -0
  12. openrewrite-8.73.0.dev20260131161045/src/rewrite/category.py +53 -0
  13. openrewrite-8.73.0.dev20260131161045/src/rewrite/decorators.py +80 -0
  14. openrewrite-8.73.0.dev20260131161045/src/rewrite/discovery.py +95 -0
  15. openrewrite-8.73.0.dev20260131161045/src/rewrite/execution.py +113 -0
  16. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/__init__.py +96 -0
  17. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/extensions.py +70 -0
  18. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/markers.py +40 -0
  19. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/markers.pyi +41 -0
  20. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/support_types.py +504 -0
  21. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/support_types.pyi +272 -0
  22. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/tree.py +4849 -0
  23. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/tree.pyi +2601 -0
  24. openrewrite-8.73.0.dev20260131161045/src/rewrite/java/visitor.py +1390 -0
  25. openrewrite-8.73.0.dev20260131161045/src/rewrite/markers.py +156 -0
  26. openrewrite-8.73.0.dev20260131161045/src/rewrite/markers.pyi +84 -0
  27. openrewrite-8.73.0.dev20260131161045/src/rewrite/marketplace.py +192 -0
  28. openrewrite-8.73.0.dev20260131161045/src/rewrite/parser.py +236 -0
  29. openrewrite-8.73.0.dev20260131161045/src/rewrite/parser.pyi +97 -0
  30. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/__init__.py +104 -0
  31. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/_parser_visitor.py +3252 -0
  32. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/add_import.py +392 -0
  33. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/dependency_workspace.py +244 -0
  34. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/extensions.py +25 -0
  35. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/markers.py +84 -0
  36. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/markers.pyi +65 -0
  37. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/printer.py +1845 -0
  38. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/recipes/__init__.py +36 -0
  39. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/recipes/change_import.py +295 -0
  40. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/recipes/remove_pass.py +126 -0
  41. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/remove_import.py +276 -0
  42. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/support_types.py +29 -0
  43. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/support_types.pyi +20 -0
  44. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/tree.py +2257 -0
  45. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/tree.pyi +1207 -0
  46. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/ty_client.py +427 -0
  47. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/type_mapping.py +792 -0
  48. openrewrite-8.73.0.dev20260131161045/src/rewrite/python/visitor.py +667 -0
  49. openrewrite-8.73.0.dev20260131161045/src/rewrite/recipe.py +349 -0
  50. openrewrite-8.73.0.dev20260131161045/src/rewrite/result.py +11 -0
  51. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/__init__.py +23 -0
  52. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/__main__.py +5 -0
  53. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/python_receiver.py +1448 -0
  54. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/python_sender.py +940 -0
  55. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/receive_queue.py +522 -0
  56. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/send_queue.py +254 -0
  57. openrewrite-8.73.0.dev20260131161045/src/rewrite/rpc/server.py +1079 -0
  58. openrewrite-8.73.0.dev20260131161045/src/rewrite/style.py +69 -0
  59. openrewrite-8.73.0.dev20260131161045/src/rewrite/test/__init__.py +62 -0
  60. openrewrite-8.73.0.dev20260131161045/src/rewrite/test/rewrite_test.py +307 -0
  61. openrewrite-8.73.0.dev20260131161045/src/rewrite/test/spec.py +176 -0
  62. openrewrite-8.73.0.dev20260131161045/src/rewrite/tree.py +201 -0
  63. openrewrite-8.73.0.dev20260131161045/src/rewrite/tree.pyi +81 -0
  64. openrewrite-8.73.0.dev20260131161045/src/rewrite/utils.py +127 -0
  65. openrewrite-8.73.0.dev20260131161045/src/rewrite/visitor.py +216 -0
  66. openrewrite-8.73.0.dev20260131161045/tests/test_marketplace.py +174 -0
  67. openrewrite-8.73.0.dev20260131161045/tests/test_replace_identity.py +196 -0
  68. openrewrite-8.73.0.dev20260131161045/tests/test_rewrite_test.py +335 -0
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: openrewrite
3
+ Version: 8.73.0.dev20260131161045
4
+ Summary: OpenRewrite automated refactoring for Python.
5
+ Author-email: "Moderne Inc." <support@moderne.io>
6
+ License: Moderne Source Available License
7
+ Project-URL: Homepage, https://github.com/openrewrite/rewrite
8
+ Project-URL: Repository, https://github.com/openrewrite/rewrite.git
9
+ Project-URL: Documentation, https://docs.openrewrite.org
10
+ Project-URL: Issues, https://github.com/openrewrite/rewrite/issues
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Code Generators
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: cbor2>=5.6.5
23
+ Requires-Dist: more_itertools>=10.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
26
+ Requires-Dist: black>=24.0.0; extra == "dev"
27
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
28
+ Provides-Extra: typing
29
+ Requires-Dist: ty>=0.0.14; extra == "typing"
30
+ Provides-Extra: publish
31
+ Requires-Dist: build>=1.0.0; extra == "publish"
32
+ Requires-Dist: twine>=5.0.0; extra == "publish"
33
+
34
+ # OpenRewrite Python
35
+
36
+ OpenRewrite automated refactoring for Python source code.
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install openrewrite
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ ```python
47
+ from rewrite.python import PythonParser
48
+ from rewrite import ExecutionContext
49
+
50
+ # Parse Python source code
51
+ parser = PythonParser()
52
+ ctx = ExecutionContext()
53
+ source_files = parser.parse(ctx, "example.py")
54
+
55
+ # Apply recipes to transform code
56
+ # ...
57
+ ```
58
+
59
+ ## Writing Recipes
60
+
61
+ ```python
62
+ from dataclasses import dataclass, field
63
+ from rewrite import Recipe, option
64
+ from rewrite.python import PythonVisitor
65
+
66
+ @dataclass
67
+ class ChangeImport(Recipe):
68
+ """Changes an import from one module to another."""
69
+
70
+ old_module: str = field(metadata=option(
71
+ display_name="Old module",
72
+ description="The module to change imports from",
73
+ example="flask"
74
+ ))
75
+
76
+ new_module: str = field(metadata=option(
77
+ display_name="New module",
78
+ description="The module to change imports to",
79
+ example="flask_restful"
80
+ ))
81
+
82
+ @property
83
+ def name(self) -> str:
84
+ return "org.openrewrite.python.ChangeImport"
85
+
86
+ @property
87
+ def display_name(self) -> str:
88
+ return "Change import"
89
+
90
+ @property
91
+ def description(self) -> str:
92
+ return "Changes an import from one module to another."
93
+
94
+ def editor(self) -> PythonVisitor:
95
+ # Implementation...
96
+ pass
97
+ ```
98
+
99
+ ## Documentation
100
+
101
+ See [docs.openrewrite.org](https://docs.openrewrite.org) for full documentation.
102
+
103
+ ## License
104
+
105
+ Moderne Source Available License - see [LICENSE.md](../LICENSE.md)
@@ -0,0 +1,72 @@
1
+ # OpenRewrite Python
2
+
3
+ OpenRewrite automated refactoring for Python source code.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install openrewrite
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from rewrite.python import PythonParser
15
+ from rewrite import ExecutionContext
16
+
17
+ # Parse Python source code
18
+ parser = PythonParser()
19
+ ctx = ExecutionContext()
20
+ source_files = parser.parse(ctx, "example.py")
21
+
22
+ # Apply recipes to transform code
23
+ # ...
24
+ ```
25
+
26
+ ## Writing Recipes
27
+
28
+ ```python
29
+ from dataclasses import dataclass, field
30
+ from rewrite import Recipe, option
31
+ from rewrite.python import PythonVisitor
32
+
33
+ @dataclass
34
+ class ChangeImport(Recipe):
35
+ """Changes an import from one module to another."""
36
+
37
+ old_module: str = field(metadata=option(
38
+ display_name="Old module",
39
+ description="The module to change imports from",
40
+ example="flask"
41
+ ))
42
+
43
+ new_module: str = field(metadata=option(
44
+ display_name="New module",
45
+ description="The module to change imports to",
46
+ example="flask_restful"
47
+ ))
48
+
49
+ @property
50
+ def name(self) -> str:
51
+ return "org.openrewrite.python.ChangeImport"
52
+
53
+ @property
54
+ def display_name(self) -> str:
55
+ return "Change import"
56
+
57
+ @property
58
+ def description(self) -> str:
59
+ return "Changes an import from one module to another."
60
+
61
+ def editor(self) -> PythonVisitor:
62
+ # Implementation...
63
+ pass
64
+ ```
65
+
66
+ ## Documentation
67
+
68
+ See [docs.openrewrite.org](https://docs.openrewrite.org) for full documentation.
69
+
70
+ ## License
71
+
72
+ Moderne Source Available License - see [LICENSE.md](../LICENSE.md)
@@ -0,0 +1,88 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "openrewrite"
7
+ description = "OpenRewrite automated refactoring for Python."
8
+ version = "8.73.0.dev20260131161045" # Updated dynamically during release
9
+ authors = [{ name = "Moderne Inc.", email = "support@moderne.io" }]
10
+ license = { text = "Moderne Source Available License" }
11
+ readme = "README.md"
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Topic :: Software Development :: Code Generators",
20
+ "Topic :: Software Development :: Quality Assurance",
21
+ "Typing :: Typed",
22
+ ]
23
+ requires-python = ">=3.10"
24
+ dependencies = [
25
+ "cbor2>=5.6.5",
26
+ "more_itertools>=10.0.0",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "pytest>=8.0.0",
32
+ "black>=24.0.0",
33
+ "ruff>=0.1.0",
34
+ ]
35
+ typing = [
36
+ "ty>=0.0.14", # Required for type attribution with Java recipes
37
+ ]
38
+ publish = [
39
+ "build>=1.0.0",
40
+ "twine>=5.0.0",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/openrewrite/rewrite"
45
+ Repository = "https://github.com/openrewrite/rewrite.git"
46
+ Documentation = "https://docs.openrewrite.org"
47
+ Issues = "https://github.com/openrewrite/rewrite/issues"
48
+
49
+ [project.entry-points."openrewrite.recipes"]
50
+ openrewrite = "rewrite:activate"
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+ include = ["rewrite", "rewrite.*"]
55
+
56
+ [tool.setuptools.package-data]
57
+ "*" = ["py.typed", "*.pyi"]
58
+
59
+ [tool.black]
60
+ line-length = 120
61
+ target-version = ["py310", "py311", "py312"]
62
+
63
+ [tool.ruff]
64
+ line-length = 120
65
+ target-version = "8.73.0.dev20260131161045"
66
+
67
+ [tool.ruff.lint]
68
+ select = ["E", "F", "I", "UP"]
69
+
70
+ [tool.ty.environment]
71
+ python-version = "8.73.0.dev20260131161045"
72
+ root = ["src"]
73
+
74
+ [tool.ty.src]
75
+ include = ["src"]
76
+
77
+ [tool.ty.rules]
78
+ # Ignored rules (ty limitations with visitor pattern architecture):
79
+ # - invalid-argument-type: ~200 errors from Self type vs concrete type in accept_*() methods
80
+ # (tracked as ty bug: https://github.com/astral-sh/ty/issues/2255)
81
+ # - unresolved-reference: TYPE_CHECKING forward references
82
+ invalid-argument-type = "ignore"
83
+ unresolved-reference = "ignore"
84
+
85
+ [tool.pytest.ini_options]
86
+ testpaths = ["tests"]
87
+ python_files = ["test_*.py", "*_test.py"]
88
+ python_functions = ["test_*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: openrewrite
3
+ Version: 8.73.0.dev20260131161045
4
+ Summary: OpenRewrite automated refactoring for Python.
5
+ Author-email: "Moderne Inc." <support@moderne.io>
6
+ License: Moderne Source Available License
7
+ Project-URL: Homepage, https://github.com/openrewrite/rewrite
8
+ Project-URL: Repository, https://github.com/openrewrite/rewrite.git
9
+ Project-URL: Documentation, https://docs.openrewrite.org
10
+ Project-URL: Issues, https://github.com/openrewrite/rewrite/issues
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Code Generators
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: cbor2>=5.6.5
23
+ Requires-Dist: more_itertools>=10.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
26
+ Requires-Dist: black>=24.0.0; extra == "dev"
27
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
28
+ Provides-Extra: typing
29
+ Requires-Dist: ty>=0.0.14; extra == "typing"
30
+ Provides-Extra: publish
31
+ Requires-Dist: build>=1.0.0; extra == "publish"
32
+ Requires-Dist: twine>=5.0.0; extra == "publish"
33
+
34
+ # OpenRewrite Python
35
+
36
+ OpenRewrite automated refactoring for Python source code.
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install openrewrite
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ ```python
47
+ from rewrite.python import PythonParser
48
+ from rewrite import ExecutionContext
49
+
50
+ # Parse Python source code
51
+ parser = PythonParser()
52
+ ctx = ExecutionContext()
53
+ source_files = parser.parse(ctx, "example.py")
54
+
55
+ # Apply recipes to transform code
56
+ # ...
57
+ ```
58
+
59
+ ## Writing Recipes
60
+
61
+ ```python
62
+ from dataclasses import dataclass, field
63
+ from rewrite import Recipe, option
64
+ from rewrite.python import PythonVisitor
65
+
66
+ @dataclass
67
+ class ChangeImport(Recipe):
68
+ """Changes an import from one module to another."""
69
+
70
+ old_module: str = field(metadata=option(
71
+ display_name="Old module",
72
+ description="The module to change imports from",
73
+ example="flask"
74
+ ))
75
+
76
+ new_module: str = field(metadata=option(
77
+ display_name="New module",
78
+ description="The module to change imports to",
79
+ example="flask_restful"
80
+ ))
81
+
82
+ @property
83
+ def name(self) -> str:
84
+ return "org.openrewrite.python.ChangeImport"
85
+
86
+ @property
87
+ def display_name(self) -> str:
88
+ return "Change import"
89
+
90
+ @property
91
+ def description(self) -> str:
92
+ return "Changes an import from one module to another."
93
+
94
+ def editor(self) -> PythonVisitor:
95
+ # Implementation...
96
+ pass
97
+ ```
98
+
99
+ ## Documentation
100
+
101
+ See [docs.openrewrite.org](https://docs.openrewrite.org) for full documentation.
102
+
103
+ ## License
104
+
105
+ Moderne Source Available License - see [LICENSE.md](../LICENSE.md)
@@ -0,0 +1,66 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/openrewrite.egg-info/PKG-INFO
4
+ src/openrewrite.egg-info/SOURCES.txt
5
+ src/openrewrite.egg-info/dependency_links.txt
6
+ src/openrewrite.egg-info/entry_points.txt
7
+ src/openrewrite.egg-info/requires.txt
8
+ src/openrewrite.egg-info/top_level.txt
9
+ src/rewrite/__init__.py
10
+ src/rewrite/category.py
11
+ src/rewrite/decorators.py
12
+ src/rewrite/discovery.py
13
+ src/rewrite/execution.py
14
+ src/rewrite/markers.py
15
+ src/rewrite/markers.pyi
16
+ src/rewrite/marketplace.py
17
+ src/rewrite/parser.py
18
+ src/rewrite/parser.pyi
19
+ src/rewrite/recipe.py
20
+ src/rewrite/result.py
21
+ src/rewrite/style.py
22
+ src/rewrite/tree.py
23
+ src/rewrite/tree.pyi
24
+ src/rewrite/utils.py
25
+ src/rewrite/visitor.py
26
+ src/rewrite/java/__init__.py
27
+ src/rewrite/java/extensions.py
28
+ src/rewrite/java/markers.py
29
+ src/rewrite/java/markers.pyi
30
+ src/rewrite/java/support_types.py
31
+ src/rewrite/java/support_types.pyi
32
+ src/rewrite/java/tree.py
33
+ src/rewrite/java/tree.pyi
34
+ src/rewrite/java/visitor.py
35
+ src/rewrite/python/__init__.py
36
+ src/rewrite/python/_parser_visitor.py
37
+ src/rewrite/python/add_import.py
38
+ src/rewrite/python/dependency_workspace.py
39
+ src/rewrite/python/extensions.py
40
+ src/rewrite/python/markers.py
41
+ src/rewrite/python/markers.pyi
42
+ src/rewrite/python/printer.py
43
+ src/rewrite/python/remove_import.py
44
+ src/rewrite/python/support_types.py
45
+ src/rewrite/python/support_types.pyi
46
+ src/rewrite/python/tree.py
47
+ src/rewrite/python/tree.pyi
48
+ src/rewrite/python/ty_client.py
49
+ src/rewrite/python/type_mapping.py
50
+ src/rewrite/python/visitor.py
51
+ src/rewrite/python/recipes/__init__.py
52
+ src/rewrite/python/recipes/change_import.py
53
+ src/rewrite/python/recipes/remove_pass.py
54
+ src/rewrite/rpc/__init__.py
55
+ src/rewrite/rpc/__main__.py
56
+ src/rewrite/rpc/python_receiver.py
57
+ src/rewrite/rpc/python_sender.py
58
+ src/rewrite/rpc/receive_queue.py
59
+ src/rewrite/rpc/send_queue.py
60
+ src/rewrite/rpc/server.py
61
+ src/rewrite/test/__init__.py
62
+ src/rewrite/test/rewrite_test.py
63
+ src/rewrite/test/spec.py
64
+ tests/test_marketplace.py
65
+ tests/test_replace_identity.py
66
+ tests/test_rewrite_test.py
@@ -0,0 +1,2 @@
1
+ [openrewrite.recipes]
2
+ openrewrite = rewrite:activate
@@ -0,0 +1,14 @@
1
+ cbor2>=5.6.5
2
+ more_itertools>=10.0.0
3
+
4
+ [dev]
5
+ pytest>=8.0.0
6
+ black>=24.0.0
7
+ ruff>=0.1.0
8
+
9
+ [publish]
10
+ build>=1.0.0
11
+ twine>=5.0.0
12
+
13
+ [typing]
14
+ ty>=0.0.14
@@ -0,0 +1,111 @@
1
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
2
+
3
+ # helps pytest to rewrite the assert statements in test.py
4
+ try:
5
+ import pytest
6
+ pytest.register_assert_rewrite("rewrite.test")
7
+ except ImportError:
8
+ pass # pytest not available, skip assert rewriting
9
+
10
+ from .category import CategoryDescriptor, LOWEST_PRECEDENCE, DEFAULT_PRECEDENCE, HIGHEST_PRECEDENCE
11
+ from .decorators import categorize, get_recipe_category
12
+ from .discovery import discover_recipes, discover_decorated_recipes_in_module
13
+ from .execution import ExecutionContext, DelegatingExecutionContext, InMemoryExecutionContext, \
14
+ RecipeRunException, LargeSourceSet, InMemoryLargeSourceSet, Result
15
+ from .marketplace import RecipeMarketplace, Python
16
+ from .recipe import Recipe, ScanningRecipe, option, OptionDescriptor, RecipeDescriptor
17
+ from .markers import *
18
+ from .parser import *
19
+ from .result import *
20
+ from .style import *
21
+ from .tree import Checksum, FileAttributes, SourceFile, Tree, PrintOutputCapture, PrinterFactory
22
+ from .utils import random_id, list_find, list_map, list_map_last
23
+ from .visitor import Cursor, TreeVisitor
24
+
25
+ __all__ = [
26
+ # Tree
27
+ 'Checksum',
28
+ 'FileAttributes',
29
+ 'SourceFile',
30
+ 'Tree',
31
+ 'PrintOutputCapture',
32
+ 'PrinterFactory',
33
+
34
+ # Utils
35
+ 'random_id',
36
+ 'list_find',
37
+ 'list_map',
38
+ 'list_map_last',
39
+
40
+ # Visitor
41
+ 'Cursor',
42
+ 'TreeVisitor',
43
+
44
+ # Execution
45
+ 'ExecutionContext',
46
+ 'DelegatingExecutionContext',
47
+ 'InMemoryExecutionContext',
48
+ 'RecipeRunException',
49
+ 'LargeSourceSet',
50
+ 'InMemoryLargeSourceSet',
51
+ 'Result',
52
+
53
+ # Recipe
54
+ 'Recipe',
55
+ 'ScanningRecipe',
56
+ 'option',
57
+ 'OptionDescriptor',
58
+ 'RecipeDescriptor',
59
+
60
+ # Categories and Marketplace
61
+ 'CategoryDescriptor',
62
+ 'LOWEST_PRECEDENCE',
63
+ 'DEFAULT_PRECEDENCE',
64
+ 'HIGHEST_PRECEDENCE',
65
+ 'RecipeMarketplace',
66
+ 'Python',
67
+ 'categorize',
68
+ 'get_recipe_category',
69
+ 'discover_recipes',
70
+ 'discover_decorated_recipes_in_module',
71
+ 'activate',
72
+
73
+ # Markers
74
+ 'Marker',
75
+ 'Markers',
76
+ 'SearchResult',
77
+ 'UnknownJavaMarker',
78
+ 'ParseExceptionResult',
79
+
80
+ # Parser
81
+ 'Parser',
82
+ 'ParserInput',
83
+ 'ParseError',
84
+ 'ParseErrorVisitor',
85
+ 'ParserBuilder',
86
+
87
+ # Style
88
+ 'Style',
89
+ 'NamedStyles',
90
+ 'GeneralFormatStyle',
91
+ ]
92
+
93
+
94
+ def activate(marketplace: RecipeMarketplace) -> None:
95
+ """
96
+ Install all recipes in this package into the marketplace.
97
+
98
+ This function is called by the discovery mechanism when the
99
+ openrewrite package is found via entry points. It installs all
100
+ the built-in Python recipes into the provided marketplace.
101
+
102
+ Args:
103
+ marketplace: The RecipeMarketplace to install recipes into
104
+ """
105
+ from rewrite.decorators import get_recipe_category
106
+ from rewrite.python.recipes import RemovePass
107
+
108
+ # Install all Python recipes with their categories
109
+ category = get_recipe_category(RemovePass)
110
+ if category is not None:
111
+ marketplace.install(RemovePass, category)
@@ -0,0 +1,53 @@
1
+ # Copyright 2025 the original author or authors.
2
+ # <p>
3
+ # Licensed under the Moderne Source Available License (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ # <p>
7
+ # https://docs.moderne.io/licensing/moderne-source-available-license
8
+ # <p>
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Category descriptor for recipe organization."""
16
+
17
+ from __future__ import annotations
18
+
19
+ from dataclasses import dataclass, field
20
+ from typing import FrozenSet
21
+
22
+ # Priority constants matching Java's CategoryDescriptor
23
+ LOWEST_PRECEDENCE = -1
24
+ DEFAULT_PRECEDENCE = 0
25
+ HIGHEST_PRECEDENCE = 2147483647 # Integer.MAX_VALUE
26
+
27
+
28
+ @dataclass(frozen=True)
29
+ class CategoryDescriptor:
30
+ """
31
+ Descriptor for a recipe category.
32
+
33
+ Categories organize recipes hierarchically in the marketplace.
34
+ Recipes are placed in categories based on their package structure
35
+ or explicit category assignments.
36
+
37
+ Attributes:
38
+ display_name: Human-readable name for the category
39
+ package_name: Dot-separated package path (e.g., "org.openrewrite.python")
40
+ description: Markdown description of the category
41
+ tags: Set of tags for filtering
42
+ root: If True, this is a root category that may be hidden in display
43
+ priority: Lower values have higher priority for conflict resolution
44
+ synthetic: True if auto-generated, False if explicitly defined
45
+ """
46
+
47
+ display_name: str
48
+ package_name: str = ""
49
+ description: str = ""
50
+ tags: FrozenSet[str] = field(default_factory=frozenset)
51
+ root: bool = False
52
+ priority: int = LOWEST_PRECEDENCE
53
+ synthetic: bool = False