Skip to content

What would be the best solution for IndentationErrors?!? #265

@cclauss

Description

@cclauss

#82 and #258 demonstrate that users are having an issue with Python's requirement that line one of a Python code block must start in column 0 or an IndentationError will be raised.

<!DOCTYPE html>
<html lang="en">
  <head>
  </head>
  <body>
    <py-script>
      print("Hello IndentationError?!?")
    </py-script>
  </body>
</html>

What would be the best (automatic) method to avoid forcing left-justification of all multiline Python code?

Could pyscript automagically left justify the Python code or would it be possible to monkey-patch IndentationError to deal with code starting at the existing indentation of the first line of Python or at least a pre-commit job to left-justify blocks of Python code. Kinda like https://docs.python.org/3/library/textwrap.html

GitHub Actions does this in YAML files: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-running-a-python-script

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions