Skip to content

[Repo Assist] [Python] Fix CLIEvent property causing unimplementable abstract Protocol member in object expressions#4492

Merged
dbrattli merged 3 commits intomainfrom
repo-assist/fix-issue-3039-clievent-python-interface-1cab4bd587885861
Apr 8, 2026
Merged

[Repo Assist] [Python] Fix CLIEvent property causing unimplementable abstract Protocol member in object expressions#4492
dbrattli merged 3 commits intomainfrom
repo-assist/fix-issue-3039-clievent-python-interface-1cab4bd587885861

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 8, 2026

Closes #3039

Root Cause

When an F# interface has a [<CLIEvent>] member, FCS exposes it as three members in MembersFunctionsAndValues:

  1. The event property getter (e.g. Event with CompiledName = "get_Event", IsGetter = true)
  2. add_Event — the subscribe accessor
  3. remove_Event — the unsubscribe accessor

Python's transformInterface included the event property getter in the generated Protocol class as an abstract member. However, transformObjectExpr only generates add_*/remove_* method overrides for [<CLIEvent>] members — it never generates an override for the event property getter. This left the Protocol with an unimplementable abstract member, causing type errors at every object expression implementing such an interface.

Fix

In transformInterface (Fable2Python.Transforms.fs), after collecting members, identify CLIEvent property members by checking whether a companion add_<name> member exists. If so, exclude the event property from the Protocol using DisplayName matching (not CompiledName, since the getter has CompiledName = "get_Event" while the extracted name from add_Event is "Event"). The add_*/remove_* accessors are retained.

Test

The previously commented-out test "test Generic interface expression can have CLI events" in tests/Python/TestEvent.fs has been reinstated (by the original bot PR). All 2267 Python tests pass.

Notes

  • This change is Python-specific and does not affect other targets
  • Shared files are not modified

🤖 Generated with Claude Code

… expressions

When an F# interface has a [<CLIEvent>] member, FCS exposes it as three
members: the event property itself (e.g. 'SomethingChanged'), plus the
add_/remove_ accessor methods. Python's transformInterface included all
three in the generated Protocol class as abstract members.

However, transformObjectExpr only generates add_/remove_ methods for
CLIEvent members — it never generates the event property override. This
left the Protocol with an unimplementable abstract member, causing
mypy/pyright type errors when using object expressions that implement
interfaces with [<CLIEvent>] members.

Fix: identify CLIEvent property members by checking whether a companion
add_<name> member exists in the same interface, and exclude them from the
Protocol. The add_/remove_ methods are retained as they correctly model
the subscription mechanism.

Fixes #3039

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation Automated changes repo-assist Created by Repo Assist labels Apr 8, 2026
The CLIEvent property getter has CompiledName "get_Event" (with prefix)
but DisplayName "Event", so the original CompiledName check never matched.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dbrattli dbrattli marked this pull request as ready for review April 8, 2026 23:04
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 8, 2026

Python Type Checking Results (Pyright)

Metric Value
Total errors 18
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_hash_set.py 3 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

Satisfies Ionide analyzer warning about implicit string comparison.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dbrattli dbrattli merged commit f481529 into main Apr 8, 2026
24 checks passed
@dbrattli dbrattli deleted the repo-assist/fix-issue-3039-clievent-python-interface-1cab4bd587885861 branch April 8, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLIEvent and Object expressions

2 participants