Skip to content

fix(mypy): _Singleton metaclass typing#1888

Merged
iamdefinitelyahuman merged 6 commits intomasterfrom
BobTheBuidler-patch-4
Jun 11, 2025
Merged

fix(mypy): _Singleton metaclass typing#1888
iamdefinitelyahuman merged 6 commits intomasterfrom
BobTheBuidler-patch-4

Conversation

@BobTheBuidler
Copy link
Copy Markdown
Collaborator

@BobTheBuidler BobTheBuidler commented Jun 5, 2025

counterintuitively, when you supply type hints for a metaclass' call method, it breaks typing for the created instances which all resolve to the __call__ method's return type (currently Any)

This PR allows all singleton-based classes to type correctly.

What I did

Related issue: #

How I did it

How to verify it

clone it and mouseover the instances in your IDE

Checklist

  • I have confirmed that my PR passes all linting checks
  • I have included test cases
  • I have updated the documentation
  • I have added an entry to the changelog

counterintuitively, when you supply type hints for a metaclass' call method, it breaks typing for the created instances which all resolve to `Any`

This PR allows all singleton-based classes to type correctly.
@BobTheBuidler BobTheBuidler marked this pull request as ready for review June 5, 2025 14:33
@iamdefinitelyahuman iamdefinitelyahuman merged commit 89afa1f into master Jun 11, 2025
15 of 25 checks passed
@iamdefinitelyahuman iamdefinitelyahuman deleted the BobTheBuidler-patch-4 branch June 11, 2025 22:55
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