Skip to content

Conversation

@spenczar
Copy link
Contributor

This adds an indent contextmanager for managing indentation depth. In practice I find this rather ergonomic and helpful. Example usage:

g.P("class Service")
with g.indent():
    g.P("def method(self):")
    with g.indent():
        g.P("x = 4 + 2")
        g.P("return x")
    g.P("")
    g.P("def another_method(self):")
    with g.indent():
        g.P("pass")

This way, indenting and dedenting in the generated code matches the source generator code.

@fischor
Copy link
Owner

fischor commented Jun 17, 2025

I like it, as the indentation of the code reflects to indentation of the generated output.
Can you rebase it to the current main branch so that we can make sure the CI pipeline stays green?

Thank you for all your PRs!

@spenczar
Copy link
Contributor Author

Sure, just rebased and force-pushed. Glad to help - thanks for making this package, it's very helpful within its little niche.

@fischor fischor merged commit acf3d67 into fischor:main Jun 17, 2025
2 checks passed
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.

2 participants