Skip to content

[BUG]: keyword-unions.schema is not valid for python testing #3119

Description

@carloscasellas

Issue Type

quicktype output (generated code cannot be used) / test coverage gap

Context (Environment, Version, Language)

Input Format:
JSON Schema

Output Language:
Python

CLI, npm, or app.quicktype.io:
CLI (also reproducible via npm package)

Version:
Current master (also present historically — this is a longstanding, still-unfixed gap)

Description

test/inputs/schema/keyword-unions.schema is a flat object with 276 properties, each a oneOf union. Generating Python from it produces a constructor call with one argument per property — 276 arguments — which exceeds CPython's hard limit of 255 arguments per call. As a result, this fixture is permanently skipped for Python:

// test/languages.ts
skipSchema: [
    "keyword-unions.schema", // Requires more than 255 arguments
],

This isn't just a test-suite inconvenience — it means quicktype can generate genuinely broken Python for any real-world schema wide enough to trip the same limit, and there's no test coverage to catch a regression or confirm a fix.

Input Data

test/inputs/schema/keyword-unions.schema — 276 properties, each shaped:
"constructor": {
    "oneOf": [
        { "type": "number" },
        { "type": "object", "additionalProperties": false, "title": "constructor" }
    ],
    "title": "union_constructor"
}

(276 properties like this, plus a trailing "dummy": {"type": "number"}.)

Expected Behaviour / Output

Generated Python for a wide object should produce valid, importable Python regardless of property count — e.g. by constructing instances via **kwargs / a dict rather than one positional argument per property, or by grouping fields.

Current Behaviour / Output

Generation succeeds, but the resulting Python is unusable — the generated init/constructor call exceeds CPython's 255-argument ceiling and raises SyntaxError: more than 255 arguments (or an equivalent error) at import/call time. Confirmed via node dist/index.js --lang python --src-lang schema test/inputs/schema/keyword-unions.schema — the widest generated call site is 276 arguments.

Steps to Reproduce

  1. npm run build
  2. node dist/index.js --lang python --src-lang schema test/inputs/schema/keyword-unions.schema
  3. Attempt to import/exercise the generated Python module
  4. Observe the argument-count error

Possible Solution

Grouping the schema's properties into smaller nested objects (e.g. 5 groups of ~56) drops the widest call site well under 255 and would let this fixture run for Python — verified locally as part of investigating #559 (unrelated issue, same fixture). That's a workaround for this schema, not a general fix: quicktype's Python renderer arguably shouldn't emit an N-argument call for arbitrarily wide objects in the first place. Worth deciding whether the fix belongs in the renderer (structural) or is accepted as an input-shape limitation (documented).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions