Skip to content

Add Python type annotations to constructor body assignments#8

Closed
google-labs-jules[bot] wants to merge 1 commit intomainfrom
python-type-annotations-constructor-body-2859604139089415028
Closed

Add Python type annotations to constructor body assignments#8
google-labs-jules[bot] wants to merge 1 commit intomainfrom
python-type-annotations-constructor-body-2859604139089415028

Conversation

@google-labs-jules
Copy link

The user wants to add Python type annotations to the instance variable assignments in the __init__ method of classes generated by the library, and update the corresponding unit tests to reflect this change.

Modified Json2SharpLib/Emitters/Python/PythonClassEmitter.cs to support type annotations in the constructor body.
Updated test expectation files in Json2SharpTests/PythonTests/Models/Answers/ for:

  • ArrayTypes.cs
  • BoolTypes.cs
  • CustomHandleTypes.cs
  • FloatTypes.cs
  • IntegerTypes.cs
  • NoneTypeHintTypes.cs
  • ObjectTypes.cs
  • TextTypes.cs
  • WeirdNameTypes.cs

Verified with dotnet test Json2SharpTests/Json2SharpTests.csproj.


PR created automatically by Jules for task 2859604139089415028 started by @FuzzyLab-Shared

…_init__` method.

I modified `Json2SharpLib/Emitters/Python/PythonClassEmitter.cs` to include type hints when assigning instance variables in the constructor body, which occurs when the `AddTypeHints` option is enabled. I also refactored the type hint generation for arrays into a reusable `GetArrayTypeHint` method and introduced a `GetPropertyType` helper to determine the correct Python types for properties, including objects and arrays.

Finally, I updated the test expectation files in `Json2SharpTests/PythonTests/Models/Answers/` to match this new format and confirmed that all unit tests pass for the .NET 8.0 target.
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@Kaoticz Kaoticz closed this Mar 1, 2026
@Kaoticz Kaoticz deleted the python-type-annotations-constructor-body-2859604139089415028 branch March 1, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant