Skip to content

Conversation

@AlexWaygood
Copy link
Member

Summary

Fixes astral-sh/ty#1218.

This bug doesn't currently cause us any real-world issues, because we don't yet understand the signatures typeshed gives us for isinstance() and issubclass() (typeshed's annotations there use PEP-613 type aliases). #20107 demonstrates that this will start causing us issues as soon as we add support for PEP-613 aliases, however, so it makes sense to fix it now.

Test Plan

Added mdtests

@AlexWaygood AlexWaygood requested a review from carljm as a code owner September 20, 2025 11:57
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Sep 20, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@AlexWaygood AlexWaygood force-pushed the alex/special-form-fallbacks branch from edc1e20 to a9459a1 Compare September 20, 2025 12:00
@github-actions
Copy link
Contributor

mypy_primer results

Changes were detected when running on open source projects
async-utils (https://github.com/mikeshardmind/async-utils)
- src/async_utils/corofunc_cache.py:56:17: error[invalid-argument-type] Argument to class `type` is incorrect: Expected `tuple[type, ...]`, found `tuple[typing.Protocol]`
- src/async_utils/task_cache.py:57:17: error[invalid-argument-type] Argument to class `type` is incorrect: Expected `tuple[type, ...]`, found `tuple[typing.Protocol]`
- Found 29 diagnostics
+ Found 27 diagnostics

spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/typing_extensions.py:1037:25: error[invalid-base] Invalid class base with type `typing.Protocol | <class 'Protocol'>`
+ lib/spack/spack/vendor/typing_extensions.py:1037:25: warning[unsupported-base] Unsupported class base with type `typing.Protocol | <class 'Protocol'>`

setuptools (https://github.com/pypa/setuptools)
- setuptools/_vendor/typing_extensions.py:572:25: error[subclass-of-final-class] Class `_ProtocolMeta` cannot inherit from final class `_SpecialForm`
- setuptools/_vendor/typing_extensions.py:833:23: error[invalid-base] Invalid class base with type `object`
- setuptools/_vendor/typing_extensions.py:844:25: error[invalid-base] Invalid class base with type `object`
- Found 774 diagnostics
+ Found 771 diagnostics
No memory usage changes detected ✅

@AlexWaygood AlexWaygood merged commit f1aacd0 into main Sep 22, 2025
39 checks passed
@AlexWaygood AlexWaygood deleted the alex/special-form-fallbacks branch September 22, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protocol not understood as an ABCMeta

3 participants