-
Notifications
You must be signed in to change notification settings - Fork 2k
Comparing changes
Open a pull request
base repository: astral-sh/ruff
base: 0.10.0
head repository: astral-sh/ruff
compare: 0.11.0
- 7 commits
- 41 files changed
- 5 contributors
Commits on Mar 13, 2025
-
[syntax-errors] Tuple unpacking in
forstatement iterator clause be……fore Python 3.9 (#16558) Summary -- This PR reuses a slightly modified version of the `check_tuple_unpacking` method added for detecting unpacking in `return` and `yield` statements to detect the same issue in the iterator clause of `for` loops. I ran into the same issue with a bare `for x in *rest: ...` example (invalid even on Python 3.13) and added it as a comment on #16520. I considered just making this an additional `StarTupleKind` variant as well, but this change was in a different version of Python, so I kept it separate. Test Plan -- New inline tests.
Configuration menu - View commit details
-
Copy full SHA for 2382fe1 - Browse repository at this point
Copy the full SHA 2382fe1View commit details
Commits on Mar 14, 2025
-
Fallback to requires-python in certain cases when target-version is n…
…ot found (#16721) ## Summary Restores #16319 after it got dropped from the 0.10 release branch :( --------- Co-authored-by: dylwil3 <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5955650 - Browse repository at this point
Copy the full SHA 5955650View commit details -
Configuration menu - View commit details
-
Copy full SHA for 14c5ed5 - Browse repository at this point
Copy the full SHA 14c5ed5View commit details -
[red-knot] Assignments to attributes (#16705)
## Summary This changeset adds proper support for assignments to attributes: ```py obj.attr = value ``` In particular, the following new features are now available: * We previously didn't raise any errors if you tried to assign to a non-existing attribute `attr`. This is now fixed. * If `type(obj).attr` is a data descriptor, we now call its `__set__` method instead of trying to assign to the load-context type of `obj.attr`, which can be different for data descriptors. * An initial attempt was made to support unions and intersections, as well as possibly-unbound situations. There are some remaining TODOs in tests, but they only affect edge cases. Having nested diagnostics would be one way that could help solve the remaining cases, I believe. ## Follow ups The following things are planned as follow-ups: - Write a test suite with snapshot diagnostics for various attribute assignment errors - Improve the diagnostics. An easy improvement would be to highlight the right hand side of the assignment as a secondary span (with the rhs type as additional information). Some other ideas are mentioned in TODO comments in this PR. - Improve the union/intersection/possible-unboundness handling - Add support for calling custom `__setattr__` methods (see new false positive in the ecosystem results) ## Ecosystem changes Some changes are related to assignments on attributes with a custom `__setattr__` method (see above). Since we didn't notice missing attributes at all in store context previously, these are new. The other changes are related to properties. We previously used their read-context type to test the assignment. That results in weird error messages, as we often see assignments to `self.property` and then we think that those are instance attributes *and* descriptors, leading to union types. Now we properly look them up on the meta type, see the decorated function, and try to overwrite it with the new value (as we don't understand decorators yet). Long story short: the errors are still weird, we need to understand decorators to make them go away. ## Test Plan New Markdown tests
Configuration menu - View commit details
-
Copy full SHA for d03b12e - Browse repository at this point
Copy the full SHA d03b12eView commit details -
[red-knot] fix: improve type inference for binary ops on tuples (#16725)
## Summary This PR includes minor improvements to binary operation inference, specifically for tuple concatenation. ### Before ```py reveal_type((1, 2) + (3, 4)) # revealed: @todo(return type of decorated function) # If TODO is ignored, the revealed type would be `tuple[1|2|3|4, ...]` ``` The `builtins.tuple` type stub defines `__add__`, but it appears to only work for homogeneous tuples. However, I think this limitation is not ideal for many use cases. ### After ```py reveal_type((1, 2) + (3, 4)) # revealed: tuple[Literal[1], Literal[2], Literal[3], Literal[4]] ``` ## Test Plan ### Added - `mdtest/binary/tuples.md` ### Affected - `mdtest/slots.md` (a test have been moved out of the `False-Negative` block.)
Configuration menu - View commit details
-
Copy full SHA for 270318c - Browse repository at this point
Copy the full SHA 270318cView commit details -
[red-knot] Preliminary tests for typing.Final (#15917)
## Summary WIP. Adds some preliminary tests for `typing.Final`. ## Test Plan New MD tests
Configuration menu - View commit details
-
Copy full SHA for a22d206 - Browse repository at this point
Copy the full SHA a22d206View commit details -
## Summary Follow-up release for Ruff v0.10 that now includes the following two changes that we intended to ship but slipped: * Changes to how the Python version is inferred when a `target-version` is not specified (#16319) * `blanket-noqa` (`PGH004`): Also detect blanked file-level noqa comments (and not just line level comments). ## Test plan I verified that the binary built on this branch respects the `requires-python` setting ([logs](https://www.diffchecker.com/qyJWYi6W/), left: v0.10, right: v0.11)
Configuration menu - View commit details
-
Copy full SHA for 2cd25ef - Browse repository at this point
Copy the full SHA 2cd25efView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff 0.10.0...0.11.0