Skip to content

Filter out Python-only exports like dataclass decorator #133

@bbopen

Description

@bbopen

Problem

The generated TypeScript code exports Python implementation details that aren't useful to TypeScript consumers:

// Generated code includes:
export async function dataclass(...): Promise<unknown>

The dataclass decorator is a Python-specific construct that shouldn't be exposed in the TypeScript API.

Current Behavior

All functions/classes found in a module are exported, including:

  • dataclass decorator
  • Other decorators (property, staticmethod, etc.)
  • Internal functions starting with _
  • Module-level helpers

Proposed Solution

  1. Built-in filter list - Automatically exclude known Python built-ins/decorators:

    • dataclass, dataclasses.dataclass
    • property, staticmethod, classmethod
    • abstractmethod, abc.abstractmethod
    • Functions starting with _
  2. Config option to exclude - Allow users to specify additional exclusions:

    export default defineConfig({
      pythonModules: {
        'my_module': {
          exclude: ['internal_helper', 'dataclass'],
          // or
          excludePatterns: ['^_', 'dataclass']
        }
      }
    });
  3. Smarter detection - Detect decorator usage patterns and don't export decorators as functions

Labels

enhancement, code-generation, breaking-change

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