ruff
7da32813 - [ty] Add more autofixes (#28029)

Commit
45 days ago
[ty] Add more autofixes (#28029) ## Summary Add a new `SemanticMode::definitely_has_builtin_binding()` that allows us to cheaply and easily query whether a builtin name such as `list` or `int` has been shadowed by a variable in an enclosing scope when viewed from a given node in the AST. Once this method is in place, it becomes much more trivial to add autofixes to various diagnostics, which this PR therefore does. The new method does not attempt to fully model Python's name-lookup semantics. It doesn't need to -- it's okay to be conservative when offering autofixes. The method therefore errs on the side of caution and only returns `true` if it can be certain that the name passed in was definitely not shadowed in an enclosing scope. The new method is similar to the `SemanticModel::has_builtin_binding()` method that Ruff has had for a long time. The new `SemanticModel` method is pulled out of https://github.com/astral-sh/ruff/pull/27634, where I'm using it for several more diagnostic autofixes that make it much easier to understand how ty is trying to tell you to rewrite your code (in my opinion). ## Test Plan mdtests and snapshots
Author
Parents
Loading