Skip to content

Conversation

@zaburo-ch
Copy link

This PR fixes a bug in ModulePrinter where the indent_char argument specified during initialization was being ignored.

Currently, the printer defaults to using a tab character (\t) for indentation, regardless of the character provided to the indent_char argument. This change ensures that the specified indent_char is correctly used when generating the output source code.

Verification

The following example demonstrates the corrected behavior.

import ast
from python_minifier.module_printer import ModulePrinter

module = ast.parse("def f():\n    while True:\n        print('hello')")

# Initialize the printer with a single space as the indent_char
printer = ModulePrinter(indent_char=" ")
result = printer(module)

# The expected output should use a space for indentation
expected = "def f():\n while True:print('hello')"

# Before this fix, the result was:
# "def f():\n\twhile True:print('hello')"

assert result == expected

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