Package org.openrewrite.python.marker
Class PythonResolutionResult
java.lang.Object
org.openrewrite.python.marker.PythonResolutionResult
- All Implemented Interfaces:
org.openrewrite.marker.Marker,org.openrewrite.rpc.RpcCodec<PythonResolutionResult>
public class PythonResolutionResult
extends Object
implements org.openrewrite.marker.Marker, org.openrewrite.rpc.RpcCodec<PythonResolutionResult>
Contains metadata about a Python project, parsed from pyproject.toml and uv.lock.
Attached as a marker to Toml.Document to provide dependency context for recipes.
The model separates requests (PythonResolutionResult.Dependency) from resolutions (PythonResolutionResult.ResolvedDependency):
- The dependency lists contain
PythonResolutionResult.Dependencyobjects (what was requested in pyproject.toml) - The resolvedDependencies list contains what was actually locked (from uv.lock)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA dependency specification parsed from a PEP 508 string in pyproject.toml.static enumstatic classA resolved (locked) dependency from uv.lock.static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable PythonResolutionResult.DependencyfindDependency(String packageName) Find a declared dependency by package name in the main[project].dependencieslist.@Nullable PythonResolutionResult.DependencyfindDependencyInAnyScope(String packageName) Find a declared dependency by package name across all scopes: dependencies, buildRequires, optionalDependencies, and dependencyGroups.Get all declared dependencies across all scopes as a flat list.getResolvedDependency(String packageName) Look up a resolved dependency by package name.static StringnormalizeName(String name) Normalize a Python package name per PEP 503: lowercase, dashes/dots/underscores are equivalent.rpcReceive(PythonResolutionResult before, org.openrewrite.rpc.RpcReceiveQueue q) voidrpcSend(PythonResolutionResult after, org.openrewrite.rpc.RpcSendQueue q) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.marker.Marker
getId, print, withId
-
Constructor Details
-
PythonResolutionResult
public PythonResolutionResult()
-
-
Method Details
-
getResolvedDependency
public @Nullable PythonResolutionResult.ResolvedDependency getResolvedDependency(String packageName) Look up a resolved dependency by package name.- Parameters:
packageName- The name of the package to look up (case-insensitive, normalized per PEP 503)- Returns:
- The resolved dependency, or null if not found
-
findDependency
Find a declared dependency by package name in the main[project].dependencieslist.- Parameters:
packageName- The name of the package (case-insensitive, normalized per PEP 503)- Returns:
- The dependency, or null if not found
-
findDependencyInAnyScope
Find a declared dependency by package name across all scopes: dependencies, buildRequires, optionalDependencies, and dependencyGroups.- Parameters:
packageName- The name of the package (case-insensitive, normalized per PEP 503)- Returns:
- The dependency, or null if not found in any scope
-
getAllDeclaredDependencies
Get all declared dependencies across all scopes as a flat list. Includes dependencies, buildRequires, optionalDependencies values, and dependencyGroups values. -
normalizeName
Normalize a Python package name per PEP 503: lowercase, dashes/dots/underscores are equivalent. -
rpcSend
- Specified by:
rpcSendin interfaceorg.openrewrite.rpc.RpcCodec<PythonResolutionResult>
-
rpcReceive
public PythonResolutionResult rpcReceive(PythonResolutionResult before, org.openrewrite.rpc.RpcReceiveQueue q) - Specified by:
rpcReceivein interfaceorg.openrewrite.rpc.RpcCodec<PythonResolutionResult>
-