Skip to content

Fix constructor headers without arguments - #839

Merged
mristin merged 1 commit into
mainfrom
mristin/Fix-constructor-headers-without-arguments
Oct 3, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/Fix-constructor-headers-without-arguments

Conversation

@mristin

@mristin mristin commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

The Python, C# and TypeScript constructors checked for no arguments and for one argument in two separate if's, so a constructor without arguments got two headers. For example, Python rendered both def __init__(self) -> None: and def __init__(\n self\n) -> None: when the constructor only called the parent constructor. We now use elif len(arg_codes) == 1:.

In C# and TypeScript the branch is not reachable at the moment, as the constructors without arguments have no inlined statements, and are not generated at all. We fix them nevertheless for consistency.

We test it with Plain_marker, which only calls Marker.__init__, in the deep_class_hierarchy meta-model, and add its JSON and XML examples for the live tests.

The Python, C# and TypeScript constructors checked for no arguments and
for one argument in two separate ``if``'s, so a constructor without
arguments got two headers. For example, Python rendered both
``def __init__(self) -> None:`` and ``def __init__(\n self\n) -> None:``
when the constructor only called the parent constructor. We now use
``elif len(arg_codes) == 1:``.

In C# and TypeScript the branch is not reachable at the moment, as
the constructors without arguments have no inlined statements, and are
not generated at all. We fix them nevertheless for consistency.

We test it with ``Plain_marker``, which only calls ``Marker.__init__``,
in the ``deep_class_hierarchy`` meta-model, and add its JSON and XML
examples for the live tests.
@mristin
mristin merged commit 22eaea0 into main Oct 3, 2026
5 checks passed
@mristin
mristin deleted the mristin/Fix-constructor-headers-without-arguments branch October 3, 2026 23:21
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37160735322

Coverage increased (+0.004%) to 90.139%

Details

  • Coverage increased (+0.004%) from the base build.
  • Patch coverage: 3 of 3 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 50208
Covered Lines: 45257
Line Coverage: 90.14%
Coverage Strength: 2.7 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants