SkillAgentSearch skills...

Py2mojo

Automated Python to Mojo code translation

Install / Use

/learn @msaelices/Py2mojo
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

py2mojo

Automated Python to Mojo code translation

A tool to automatically convert Python code to the new Mojo programming language.

Installation

pip install py2mojo

Usage

You can read the usage by running py2mojo --help:

❯ py2mojo --help
usage: py2mojo [-h] [--inplace] [--extension {mojo,🔥}] [--convert-def-to-fn | --no-convert-def-to-fn] [--convert-class-to-struct | --no-convert-class-to-struct] [--float-precision {32,64}]
               filenames [filenames ...]

positional arguments:
  filenames

options:
  -h, --help            show this help message and exit
  --inplace             Rewrite the file inplace
  --extension {mojo,🔥}  File extension of the generated files
  --convert-def-to-fn, --no-convert-def-to-fn
  --convert-class-to-struct, --no-convert-class-to-struct
  --float-precision {32,64}

Examples:

❯ py2mojo myfile.py
❯ py2mojo mypackage/*.py

⚠ Disclaimer

Please be aware that the Mojo programming language is still in its nascent stages of development. As with any young language, there might be frequent updates, changes, and unforeseen quirks in its syntax and behavior. There will probably be instances where the conversion might not work and may require manual adjustments.

So, consider this tool as experimental. Please do not trust the generated code and double-check it.

Implementation details

This uses a similar approach to the pyupgrade tool, using the AST parser to analyze the Python code and replace some parts of it with the equivalent Mojo code.

As Mojo is a superset of Python, non-replaced logic should be also a valid Mojo code.

Contributing

How to install it locally

  1. Fork the repository

  2. Clone your fork:

git clone git@github.com:youraccount/py2mojo.git
  1. Install it locally:
cd py2mojo
pip install -e .
View on GitHub
GitHub Stars148
CategoryDevelopment
Updated3d ago
Forks12

Languages

Python

Security Score

95/100

Audited on Apr 2, 2026

No findings