Skip to content

@overload functions injected via NUKE_POST_INJECT are missing a function body, causing IndentationError #9

@pushkarev-alexandr

Description

@pushkarev-alexandr

Description

NUKE_POST_INJECT injects @overload decorated function signatures into the generated nuke/__init__.py, but the strings do not include a function body (...). This causes an IndentationError when importing the stubs outside of Nuke's interpreter.

Error

File "stubs/nuke/__init__.py", line 2631
    @overload
    ^
IndentationError: expected an indented block after function definition on line 2629

Root Cause

In nukestubsgen.py, NUKE_POST_INJECT contains:

NUKE_POST_INJECT = {
    '__init__': [
        '@overload\ndef execute(nameOrNode: Node | str, frameRangeSet: FrameRange, ...) -> None:',
        '@overload\ndef execute(nameOrNode: Node | str, start: Optional[int] = None, ...) -> None:',
    ]
}

Python requires a function body after a def statement. The missing ... placeholder makes the generated file syntactically invalid.

Fix

Add \n ... to each injected function string:

NUKE_POST_INJECT = {
    '__init__': [
        '@overload\ndef execute(nameOrNode: Node | str, frameRangeSet: FrameRange, ...) -> None:\n    ...',
        '@overload\ndef execute(nameOrNode: Node | str, start: Optional[int] = None, ...) -> None:\n    ...',
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions