Skip to content

Add hasattr checks for remaining protocol isinstance checks#7505

Merged
nateprewitt merged 1 commit into
mainfrom
hasattr
Jun 9, 2026
Merged

Add hasattr checks for remaining protocol isinstance checks#7505
nateprewitt merged 1 commit into
mainfrom
hasattr

Conversation

@nateprewitt

Copy link
Copy Markdown
Member

This PR is a successor to #7502. The proxied-read case appears in the standard library which points to it being a pretty well established pattern. A quick search shows there are two other places this was missed in.

Rather than put or hasattr(data, "read") everywhere we use want to use SupportsRead, this combines it into a single check that scopes typing correctly for proxy objects. That should hopefully avoid missing it for future checks as well.

@nateprewitt nateprewitt merged commit 6f66281 into main Jun 9, 2026
109 of 111 checks passed
@nateprewitt nateprewitt deleted the hasattr branch June 9, 2026 15:46
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