Skip to content

j2pyi: More improvements#56

Open
mikehearn wants to merge 6 commits intooracle:mainfrom
mikehearn:j2pyi
Open

j2pyi: More improvements#56
mikehearn wants to merge 6 commits intooracle:mainfrom
mikehearn:j2pyi

Conversation

@mikehearn
Copy link
Contributor

Description

This PR fixes various issues in the pyinterfacegen module and makes usability improvements:

  • Improves the README.
  • You can now explicitly specify with globs and regex what other packages you expect to be typed. Anything that doesn't match will be emitted as untyped. This works better than trying to guess based on dependencies as e.g. the JDK doesn't come with Python type stubs!
  • Refactored the code by splitting parts out to a separate utility file.
  • Fixed various bugs especially around generics and overload emission, where there have been a lot of edge cases and issues.

How Has This Been Tested?

With these changes I can generate and type check .pyi stubs for quite sophisticated Java modules like Micronaut Core.

I test with the unit tests and by using the typecheckApacheCommonsStubs Gradle task.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

1. Conflicts between static and non-static methods with the same name.
2. Unused imports.
- Drop type parameters bounded by Throwable/Exception (Python can't model generic exceptions).

- Drop class type parameters that don't appear in exposed Python types after platform-type scrubbing.

- When a TypeVar is used within an invariant container (list/set/dict), don't infer variance for Protocol TypeVars.

Signed-off-by: Mike Hearn <michael.hearn@oracle.com>
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 26, 2026
# pyinterfacegen

This is a JavaDoc and Gradle plugin that generates a Python module designed for use with GraalPy. The Python module consists of:
This is a JavaDoc and Gradle plugin that generates Python modules designed for binding Java libraries to GraalPy. The Python module consists of:
Copy link
Member

@olyagpl olyagpl Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaDoc -> Javadoc
For consistency :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants