Skip to content

Python Source Code & Indention #141

@crepererum

Description

@crepererum

What

Strip indention from Python source code a la (line endings are marked):

Everything Indented

··CREATE FUNCTION add_one()|
··LANGUAGE python|
··AS '|
··def add_one(x: int) -> int:|
······|
······return x + 1|
··';|
··|
··SELECT add_one(1);|

Empty Lines NOT Intended

··CREATE FUNCTION add_one()|
··LANGUAGE python|
··AS '|
··def add_one(x: int) -> int:|
|
······return x + 1|
··';|
|
··SELECT add_one(1);|

Python Further Indented

··CREATE FUNCTION add_one()|
··LANGUAGE python|
··AS '|
······def add_one(x: int) -> int:|
··········return x + 1|
······';|
··|
··SELECT add_one(1);|

Why

Python will trip over this like:

IndentationError: unexpected indent

Now you may also wonder "why would anyone indent ALL of SQL?" Well, marimo for example does for SQL cells and I'm sure there are others.

How

There are multiple levels where we could fix this:

  1. The integrating application (i.e. whoever uses this repo)
  2. The source code extraction (see feat: implement stateless udf registration #97)
  3. The Python UDF in guests/python

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions