agentsclimarketplace

Python scala syntax mapping

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-opus-4-6/python-scala-translation/python-scala-syntax-mapping

Reference for translating Python syntax constructs (enums, dataclasses, type vars, protocols) to Scala equivalents.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill python-scala-syntax-mapping

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.6 KB, 366 tokens by cl100k_base, as published. Nobody here has run it

Python to Scala Syntax Mapping

Enums

Python Enum -> Scala sealed trait + case objects or Enumeration:

// Preferred: sealed trait for pattern matching exhaustiveness
sealed abstract class TokenType(val value: String)
object TokenType {
  case object STRING extends TokenType("string")
  case object NUMERIC extends TokenType("numeric")
}

Dataclasses (frozen=True) -> Case Classes

// Python: @dataclass(frozen=True) with default fields
// Scala: case class (immutable by default)
case class Token(value: String, tokenType: TokenType, metadata: Map[String, Any] = Map.empty)

TypeVar -> Type Parameters

// Python: T = TypeVar("T")           -> [T]
// Python: T_co = TypeVar(covariant)  -> [+T]
// Python: T_contra = TypeVar(contra) -> [-T]
// Python: NumericT = TypeVar("NumericT", int, float, Decimal) -> type class or union

Protocol -> Trait (structural typing)

// Python Protocol -> Scala trait
trait Tokenizable {
  def toToken: String
}

Optional / Union

// Python: Optional[X] -> Scala: Option[X]
// Python: X | None -> Scala: Option[X]
// Python: Union[A, B] -> Scala: Either[A, B] or sealed trait or overloaded methods

Default Mutable Args

Python allows mutable defaults (anti-pattern). Scala avoids this:

// Python: def __init__(self, opts: dict = {}):
// Scala:  def this(opts: Map[String, Any] = Map.empty)

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.