Skip to content

gh-92810: Cover ABCMeta instancecheck/subclasscheck with more tests#144941

Open
dolfinus wants to merge 2 commits intopython:mainfrom
dolfinus:improvement/abc-isinstance-tests
Open

gh-92810: Cover ABCMeta instancecheck/subclasscheck with more tests#144941
dolfinus wants to merge 2 commits intopython:mainfrom
dolfinus:improvement/abc-isinstance-tests

Conversation

@dolfinus
Copy link

@dolfinus dolfinus commented Feb 18, 2026

@bedevere-app
Copy link

bedevere-app bot commented Feb 18, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@dolfinus
Copy link
Author

dolfinus commented Feb 18, 2026

Note: I've covered case with __subclasscheck__ to ensure that behavior remains the same even if the internals of ABCMeta change. But it's mostly an implementation details, not a public contract. I haven't found documentation which covers or recommends using it.

I also haven't found any evidence that it is used in the wild, by using Github search. __subclasscheck__ are used in mocks, custom non-ABC metaclasses and in typeshed annotations:
https://github.com/search?q=%22def+__subclasses__%22+language%3APython&type=code&ref=advsearch&p=1
https://github.com/search?q=%22__subclasses__+%3D%22+language%3APython&type=code&ref=advsearch&p=1

@bedevere-app
Copy link

bedevere-app bot commented Feb 18, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

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

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments