mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 20:24:27 +00:00
## Summary
cf. https://github.com/astral-sh/ruff/pull/20962
In the following code, `foo` in the comprehension was not reported as
unresolved:
```python
# error: [unresolved-reference] "Name `foo` used when not defined"
foo
foo = [
# no error!
# revealed: Divergent
reveal_type(x) for _ in () for x in [foo]
]
baz = [
# error: [unresolved-reference] "Name `baz` used when not defined"
# revealed: Unknown
reveal_type(x) for _ in () for x in [baz]
]
```
In fact, this is a more serious bug than it looks: for `foo`,
[`explicit_global_symbol` is
called](
|
||
|---|---|---|
| .. | ||
| annotated.md | ||
| any.md | ||
| callable.md | ||
| deferred.md | ||
| int_float_complex.md | ||
| invalid.md | ||
| literal.md | ||
| literal_string.md | ||
| never.md | ||
| new_types.md | ||
| optional.md | ||
| self.md | ||
| starred.md | ||
| stdlib_typing_aliases.md | ||
| string.md | ||
| union.md | ||
| unsupported_special_forms.md | ||
| unsupported_special_types.md | ||
| unsupported_type_qualifiers.md | ||