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.Dependency objects (what was requested in pyproject.toml)
  • The resolvedDependencies list contains what was actually locked (from uv.lock)
  • 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

      public @Nullable PythonResolutionResult.Dependency findDependency(String packageName)
      Find a declared dependency by package name in the main [project].dependencies list.
      Parameters:
      packageName - The name of the package (case-insensitive, normalized per PEP 503)
      Returns:
      The dependency, or null if not found
    • findDependencyInAnyScope

      public @Nullable PythonResolutionResult.Dependency findDependencyInAnyScope(String packageName)
      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

      public List<PythonResolutionResult.Dependency> getAllDeclaredDependencies()
      Get all declared dependencies across all scopes as a flat list. Includes dependencies, buildRequires, optionalDependencies values, and dependencyGroups values.
    • normalizeName

      public static String normalizeName(String name)
      Normalize a Python package name per PEP 503: lowercase, dashes/dots/underscores are equivalent.
    • rpcSend

      public void rpcSend(PythonResolutionResult after, org.openrewrite.rpc.RpcSendQueue q)
      Specified by:
      rpcSend in interface org.openrewrite.rpc.RpcCodec<PythonResolutionResult>
    • rpcReceive

      public PythonResolutionResult rpcReceive(PythonResolutionResult before, org.openrewrite.rpc.RpcReceiveQueue q)
      Specified by:
      rpcReceive in interface org.openrewrite.rpc.RpcCodec<PythonResolutionResult>