Skip to content

Add support for duck types with multiple methods to TypesExplainer - #1631

Merged
lsegal merged 1 commit into
lsegal:mainfrom
dmolesUC:duck-type-method-lists
Dec 5, 2025
Merged

Add support for duck types with multiple methods to TypesExplainer#1631
lsegal merged 1 commit into
lsegal:mainfrom
dmolesUC:duck-type-method-lists

Conversation

@dmolesUC

@dmolesUC dmolesUC commented Oct 8, 2025

Copy link
Copy Markdown

Description

Discussion

I agree with the sentiment expressed in that comment that doing this is not a great idea, and in general, it would be better to define an ad-hoc "interface" type. But there are times when you're dealing with an obnoxious third-party library, and you just need to document something in one place, and introducing a whole type for that feels like overkill.

This is a basic implementation that just covers this use case, but I could see an argument for instead supporting & for intersection types in general (and maybe | as well as , for union types while we're at it), which wouldn't be much more code.

Completed Tasks

  • I have read the Contributing Guide.
  • The pull request is complete (implemented / written).
  • Git commits have been cleaned up (squash WIP / revert commits).
  • I wrote tests and ran bundle exec rake locally (if code is attached to PR).

@lsegal
lsegal merged commit e946455 into lsegal:main Dec 5, 2025
21 checks passed
@lsegal

lsegal commented Dec 5, 2025

Copy link
Copy Markdown
Owner

Sorry for the delay, thanks for this!

@Kushmanmb Kushmanmb 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.

Kushmanmb

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.

4 participants