facebook / facebook/pyrefly

Pyrefly ignores suppressions after multi-line nested strings in f-strings

Open
#4,118 2 comments 0 reactions 0 assignees View on GitHub
google help wanted stale
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

Pyrefly fails to recognize ignore comments if they appear after an f-string that contains a nested triple-quoted string spanning multiple lines e.g.
```python
# Corrupt the state with nested triple quotes in f-string
_ = f'start{"""message
"""}end'
y: int = "hello" # pyrefly: ignore[bad-assignment]
```
Pyrefly still errors in the last line.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxAAQDCuATgwK7EAu1bAFjNXG6ja8A7hG7V08IZk4MIxWNQCOzXELjUI6amAC0-OegDmAHXQB9agF4dAcn6oGbYCZCvXAW3hojMM%2B7cQAF8YLFt-dDNSRE10DhtXHigoXFdqahoyBhgwKGjNI3RGXmxUTF1UODgIQq84sxAAGhAsnLzCNlwPKAoaAAVSbNzSPgwcAmoAY1x0SCNmBkEIGcIzGgBlGF4uNjZiOEQAekPW4cJGI0PQw8xcSbhD6dmahaWZw51GalQAN1RoVDYRRPOavNjLbS4dgQuCrdBkbgzXQ-GAMaozazUVwAZkIAEYAEzudAAbVRDEYcAAumZmOgIB5iIxpLpMBBspNwSjMbYakVsuF0EU2Lpsip2TBygBrGCkCqTSbeHnCRzoQXBZqoTkQFEAMWgMAoaCweCIZGCQA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the sandbox reproduction in the issue and trace how Pyrefly handles ignore comments after nested triple-quoted strings inside f-strings. Done means the `pyrefly: ignore[bad-assignment]` comment suppresses the reported error for this example and a regression test covers the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.