Skip to content

n08i40k/java2pyi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java2pyi

project-image

Java‑to‑PYI is a Rust tool that parses Java source into a preprocessed AST and generates Python stub files (.pyi) with type definitions only. It was originally designed to generate class declarations to provide accurate type hints in the Telegram codebase when developing Exteragram plugins.

Installation from crates.io

cargo install java2pyi

Building from source code and installation steps

  1. Clone this repo
git clone https://github.com/n08i40k/java2pyi
  1. Compile and install
cargo install --path .

Usage example

  1. Clone OpenJDK source code (required for all use-cases, otherwise, non-promitive java types won't be resolved)
git clone https://github.com/openjdk/jdk
  1. Remove sample file from OpenJDK source code
rm ./jdk/src/java.base/share/classes/java/lang/snippet-files/ProcessExamples.java
  1. Clone Telegram for Android source code
git clone https://github.com/DrKLO/Telegram
  1. Create directory for stub files
mkdir stubs
  1. Start generator
java2pyi -i ./jdk/src/java.base/share/classes/java/ -i ./Telegram/TMessagesProj/src/main/java/ -o ./stubs

Where -i is directories with .java files and -o is output directory for generated stubs.

About

Java source to Python stubs for mypy/pyright.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages