PEP 604 `isinstance` support (unions should be treated as runtime types)
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
within an `isinstance` call, the following is valid at runtime (in Python 3.10+)
`isinstance(x, str | os.PathLike)`
while the following isn't
`isinstance(x, str | os.PathLike[str])`
Under `preset = "strict"`, pyrefly 1.0.0 flags the former and incorrectly suggests the latter. Meanwhile, it (correctly) doesn't flag `isinstance(x, os.PathLike)`, suggesting that it cannot tell that the unions in the first two calls need to be treated as runtime types, which I guess amounts to pyrefly not understanding PEP 604
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABLnADroceYxhOoBjATGIMA%2BnAZ0xxVAwAWYgIwAKYohZxCABTnyAMhADWMANqS6AXQCUiDkwdMIfCHAjpJGYWoA0mnXqGJrZMAMQsRvaO0cR07gwqbCCyClDGMEnWUQ4wUHAwdujR0XSorjBMACqkxDAAonR09FycWLz8QiLiFjJ6YgBMahqsAQpBZhY2hdHOTm4eDF4wvkwWTAA%2B-rpj6eZSU2FMYKh5FegwAOZyEABuGUXFDrHxicl6aSaZ2Uy5%2BdOPTFK5SqNXqjWarW47UEwlEEikvQUYgAzEMtoFdpNbN9Zq53J50N5iH41psRtsDOkQuFjqcmLQ3AxbvcAfS4ugEkkUvIPhkQFkHjlTv9HkD8iDag0mnQQD5kqQ6LwoKRCAxcFQoBRwtoFUrSKsMDgCEwBLh0JALgBXUpMs2EDjhADKMAq8gYDGIcEQAHpvWRFWBlYR6BdvTB0N7MLgBHBvabzRArTaIGbvUd6PwbmUoKhsLATWaLdbrmaWKIUx57egyAozQBaO50NylgC8TCSyMISn6SQ4sXgMGYbaSFggAgYvfQphg4Kblg4lvQ1FojBgmDrmAgivHzKYbYA5In0PQYPuOMeGHXFQBHS1btd1kykOsw%2BBwPdMfcAd1QdHQZ-QEAAF85UEJk7gAMWgGAKDQLA8CIMhgKAA
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.