pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

False positive on parenthezised del statements

Open sk- opened this issue 1 month ago • 3 comments

Describe the Bug

del (a, b) is valid Python and runs fine, but pyrefly 1.3.2 reports it as an invalid target (unsupported-delete)

The following code shows the issue

a = 1
b = 2
del (a, b)
$ pyrefly check mre.py
ERROR Invalid target for `del` [unsupported-delete]
 --> mre.py:3:5
  |
3 | del (a, b)
  |     ^^^^^^
Expected: no error, same as del a, b. del [a, b] fails the same way; del (a) and del (x["k"]) are accepted.

This matters in practice because both ruff and black emit this form whenever the target list exceeds the line length.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.w1VkJgJtM4zJSwJSRqBkmaOgkaijkKSJ6WtlhQCIgALUAGB-BwZXeimwVAEGg15MnjKwQElVyCgpKSi20teHac8vStdPzdNPyU8u1kfRoa8AiuDEssRMcFmFapxCPjiWioHGUhLc6pDQVscX2OqgsAaqwBt-AA

(Only applicable for extension issues) IDE Information

No response

sk- avatar Oct 09 '26 12:10 sk-

Thanks for the report! This reproduces on main for both del (a, b) and del [a, b], because pyrefly treated the parenthesized or bracketed list as one invalid target instead of deleting each name in it: https://pyrefly.org/sandbox/?project=v2.q8ZRZCbqKCQBixodBWABA0waaUDLDXUUjHQUjHUUTHQUTHUUzECpNUcBpFBBQVkhtaIAlBgV8sCpDCSjAdKtiSxXmldcWgDzfGpOaglUZTTIhlhCKvH6AwA A small fix is being prepared, and this will close once it lands.

shahhamdihassan avatar Oct 14 '26 15:10 shahhamdihassan

Thanks for the report! The fix has landed and will be in the next release.

shahhamdihassan avatar Oct 16 '26 21:10 shahhamdihassan

For anyone coming here, this is still not released and will be released in version 1.5.0

sk- avatar Nov 13 '26 15:11 sk-