Skip to content

fix: exclude instance methods from enum member detection#1921

Closed
Dhruva-Das wants to merge 1 commit into
dottxt-ai:mainfrom
Dhruva-Das:fix/enum-instance-methods-1915
Closed

fix: exclude instance methods from enum member detection#1921
Dhruva-Das wants to merge 1 commit into
dottxt-ai:mainfrom
Dhruva-Das:fix/enum-instance-methods-1915

Conversation

@Dhruva-Das

Copy link
Copy Markdown

Problem

Defining an Enum with regular instance methods (e.g. a describe(self) helper) and passing it to python_types_to_terms crashes with a signature parsing error. _get_enum_members in dsl.py treats any FunctionType found in the class body as an enum member value, so it picks up instance methods alongside the actual enum values.

Fix

Instance methods defined in a class body have ClassName.method_name in their __qualname__, while standalone functions used as enum values don't contain a dot. Added a check against __qualname__ to filter them out.

One-line change in _get_enum_members, plus a regression test.

Testing

  • Added describe(self) method to the existing SomeEnum in test_dsl_python_types_to_terms
  • Added standalone regression test test_enum_with_instance_method_not_treated_as_member covering a standard Enum with a helper method
  • pytest tests/types/test_dsl.py passes (57 passed, 2 pre-existing Windows tempfile failures unrelated to this change)

Fixes #1915

_get_enum_members treated any FunctionType in the enum body as a
generation choice. Instance methods like describe(self) have a dot
in their __qualname__ (ClassName.method), so filter them out to
avoid crashing on the unannotated self parameter.

Fixes dottxt-ai#1915
Copilot AI review requested due to automatic review settings July 13, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RobinPicard

Copy link
Copy Markdown
Contributor

Thanks for opening a PR, but the issue was already fixed by #1917

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.

Enum output types: any plain instance method on the class gets treated as a generation choice

3 participants