mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
![]() Fixes: https://github.com/astral-sh/ty/issues/1173 <!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary This PR will change the logic of binding Self type variables to bind self to the immediate function that it's used on. Since we are binding `self` to methods and not the class itself we need to ensure that we bind self consistently. The fix is to traverse scopes containing the self and find the first function inside a class and use that function to bind the typevar for self. If no such scope is found we fallback to the normal behavior. Using Self outside of a class scope is not legal anyway. ## Test Plan Added a new mdtest. Checked the diagnostics that are not emitted anymore in [primer results](https://github.com/astral-sh/ruff/pull/20366#issuecomment-3289411424). It looks good altough I don't completely understand what was wrong before. --------- Co-authored-by: Douglas Creager <dcreager@dcreager.net> |
||
---|---|---|
.. | ||
module_resolver | ||
semantic_index | ||
types | ||
util | ||
ast_node_ref.rs | ||
db.rs | ||
dunder_all.rs | ||
lib.rs | ||
lint.rs | ||
list.rs | ||
module_name.rs | ||
node_key.rs | ||
place.rs | ||
program.rs | ||
pull_types.rs | ||
python_platform.rs | ||
rank.rs | ||
semantic_index.rs | ||
semantic_model.rs | ||
site_packages.rs | ||
suppression.rs | ||
types.rs | ||
unpack.rs |