Distinguish between `AnyStyle::Implicit` and `AnyStyle::Error` in `reveal_type`
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
I was using the new `no-any-return` feature in 1.2.0.dev2 and noticed that it does not trigger on `AnyStyle::Error` (removed from my initial implementation) as a result of `ignore-missing-imports`.
```
from typing import Any, reveal_type
from mylib import doesnt_exist
def any_error() -> int:
x = doesnt_exist()
reveal_type(x)
return x # No error.
def does_exist(x):
return x
def any_implicit() -> int:
x = does_exist(5)
reveal_type(x)
return x # E: no-any-return-implicit
```
`any_error` will not report `no-any-return` since x is presumably of `AnyStyle::Error`. But both `reveal_type` calls show `x` as `Unknown`:
```
INFO sandbox.py:6:16-19: revealed type: Unknown [[reveal-type](https://pyrefly.org/en/docs/error-kinds/#reveal-type)]
INFO sandbox.py:14:16-19: revealed type: Unknown [[reveal-type](https://pyrefly.org/en/docs/error-kinds/#reveal-type)]
```
This made it hard to debug the actual issue. I assumed it was a `pyrefly` bug as first because of it saying `Unknown`, when the real bug is that my import is missing. Could there be a distinction from `AnyStyle::Implicit` and `AnyStyle::Error` in `reveal_type` and possibly even LSP? It would help me understand why an error does not appear from `pyrefly`.
---
Somewhat related, `ignore-missing-imports` is defined as:
> Instruct Pyrefly to replace the given [ModuleGlob](https://pyrefly.org/en/docs/configuration/#module-globbing)s with typing.Any and ignore import errors for the module only when the module can't be found.
But the `typing.Any` from `ignore-missing-imports` does not propagate `no-any-return` or `implicit-any` errors. I see the pros and cons of both options, but I think the documentation is a little misleading as it stands.
### Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0BBdKQA0dSjABuMVFAD6TYjAA66MNXo1SUCNk7de-TLnjoGcmPghwGq1Zhhg6GUhcrVKACgCUdALQAfJxmiKp04XT4dAC8dMam5pbWDD5hERLSsgrMMJ743mnhEgwArpTokXZYjnEmcBZWNnneoRXpMKXllej2NS5yXMQ6AMYQKb6BwQytEXSkMXQArIWRC-H1SU2kBW1FUjLyirn5K8VlFfiqICIgZBJgUKSEDLRQFADEdAAKpPePdGgsHgosNcGoIGwyqgGBAwYRVJ8AMowGB0AAWDAYxDgiAA9Li7o5HoReGxcTB0LjjMM4LjQeDIZRobDKXQwLxnJJUNBUNhYHR6ZBGcywXRcMQYWC4PD0GQGGiwX5pJQ4CyFsoQABmQgARgATBrVBD0LwYH4aNZVew-INDHAFgBtDUAKg1AF1VMQJHAOuqQDZKBBhrYQKoHTB3Lw4B70CV0La%2BDBMH5MBAJMGINIFgByY2m7OqE0MPwSACOJTTSb8AGsYKQ-KhhsN4PbYtmAO6ocoF9AmhvCEsdc45iMeHtXAC%2BN0bMOkADFoDAKICcAQSOQJ0A
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Research direction
Start with the linked sandbox example and trace how AnyStyle::Implicit and AnyStyle::Error are represented by reveal_type. Then inspect the ignore-missing-imports configuration documentation and determine the intended distinction for reveal_type and, if in scope, LSP output; done means missing-import Any is distinguishable from implicit Any and the documentation matches the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100