-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Comparing changes
Open a pull request
base repository: astral-sh/ruff
base: refs/tags/0.9.0
head repository: astral-sh/ruff
compare: 0.9.1
- 16 commits
- 54 files changed
- 12 contributors
Commits on Jan 9, 2025
-
[
pycodestyle
] Handle each cell separately for `too-many-newlines-at……-end-of-file` (`W391`) (#15308) Jupyter notebooks are converted into source files by joining with newlines, which confuses the check [too-many-newlines-at-end-of-file (W391)](https://docs.astral.sh/ruff/rules/too-many-newlines-at-end-of-file/#too-many-newlines-at-end-of-file-w391). This PR introduces logic to apply the check cell-wise (and, in particular, correctly handles empty cells.) Closes #13763
Configuration menu - View commit details
-
Copy full SHA for b0905c4 - Browse repository at this point
Copy the full SHA b0905c4View commit details -
[red-knot] Move
UnionBuilder
tests to Markdown (#15374)## Summary This moves almost all of our existing `UnionBuilder` tests to a Markdown-based test suite. I see how this could be a more controversial change, since these tests where written specifically for `UnionBuilder`, and by creating the union types using Python type expressions, we add an additional layer on top (parsing and inference of these expressions) that moves these tests away from clean unit tests more in the direction of integration tests. Also, there are probably a few implementation details of `UnionBuilder` hidden in the test assertions (e.g. order of union elements after simplifications). That said, I think we would like to see all those properties that are being tested here from *any* implementation of union types. And the Markdown tests come with the usual advantages: - More consice - Better readability - No re-compiliation when working on tests - Easier to add additional explanations and structure to the test suite This changeset adds a few additional tests, but keeps the logic of the existing tests except for a few minor modifications for consistency. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: T-256 <132141463+T-256@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for b33cf5b - Browse repository at this point
Copy the full SHA b33cf5bView commit details
Commits on Jan 10, 2025
-
[red-knot] Consolidate all gradual types into single Type variant (#1…
…5386) Prompted by > One nit: I think we need to consider `Any` and `Unknown` and `Todo` as all (gradually) equivalent to each other, and thus `type & Any` and `type & Unknown` and `type & Todo` as also equivalent. The distinction between `Any` vs `Unknown` vs `Todo` is entirely about provenance/debugging, there is no type level distinction. (And I've been wondering if the `Any` vs `Unknown` distinction is really worth it.) The thought here is that _most_ places want to treat `Any`, `Unknown`, and `Todo` identically. So this PR simplifies things by having a single `Type::Any` variant, and moves the provenance part into a new `AnyType` type. If you need to treat e.g. `Todo` differently, you still can by pattern-matching into the `AnyType`. But if you don't, you can just use `Type::Any(_)`. (This would also allow us to (more easily) distinguish "unknown via an unannotated value" from "unknown because of a typing error" should we want to do that in the future) --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Carl Meyer <carl@astral.sh>
Configuration menu - View commit details
-
Copy full SHA for baf0683 - Browse repository at this point
Copy the full SHA baf0683View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3d9433c - Browse repository at this point
Copy the full SHA 3d9433cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 23ad319 - Browse repository at this point
Copy the full SHA 23ad319View commit details -
[
ruff
] Omit diagnostic for shadowed private function parameters in ……`used-dummy-variable` (`RUF052`) (#15376)
Configuration menu - View commit details
-
Copy full SHA for 443bf38 - Browse repository at this point
Copy the full SHA 443bf38View commit details -
Configuration menu - View commit details
-
Copy full SHA for b861551 - Browse repository at this point
Copy the full SHA b861551View commit details -
[red-knot] Move intersection type tests to Markdown (#15396)
## Summary [**Rendered version of the new test suite**](https://github.com/astral-sh/ruff/blob/david/intersection-type-tests/crates/red_knot_python_semantic/resources/mdtest/intersection_types.md) Moves most of our existing intersection-types tests to a dedicated Markdown test suite, extends the test coverage, unifies the notation for these tests, groups tests into a proper structure, and adds some explanations for various simplification strategies. This changeset also: - Adds a new simplification where `~Never` is removed from intersections. - Adds a new simplification where adding `~object` simplifies the whole intersection to `Never` - Avoids unnecessary assignment-checks between inferred and declared type. This was added to this changeset to avoid many false positive errors in this test suite. Resolves the task described in this old comment [here](https://github.com/astral-sh/ruff/pull/13962/files/e01da82a5a0ef6a2af0aa4dc50f898cffadb4a33..e7e432bca2b3f24979da55a9a34ad765aaaae8d1#r1819924085). ## Test Plan Running the new Markdown tests --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Configuration menu - View commit details
-
Copy full SHA for f2c3ddc - Browse repository at this point
Copy the full SHA f2c3ddcView commit details -
Insert the cells from the
start
position (#15398)## Summary The cause of this bug is from #12575 which was itself a bug fix but the fix wasn't completely correct. fixes: #14768 fixes: astral-sh/ruff-vscode#644 ## Test Plan Consider the following three cells: 1. ```python class Foo: def __init__(self): self.x = 1 def __str__(self): return f"Foo({self.x})" ``` 2. ```python def hello(): print("hello world") ``` 3. ```python y = 1 ``` The test case is moving cell 2 to the top i.e., cell 2 goes to position 1 and cell 1 goes to position 2. Before this fix, it can be seen that the cells were pushed at the end of the vector: ``` 12.643269917s INFO ruff:main ruff_server::edit::notebook: Before update: [ NotebookCell { document: TextDocument { contents: "class Foo:\n def __init__(self):\n self.x = 1\n\n def __str__(self):\n return f\"Foo({self.x})\"", }, }, NotebookCell { document: TextDocument { contents: "def hello():\n print(\"hello world\")", }, }, NotebookCell { document: TextDocument { contents: "y = 1", }, }, ] 12.643777667s INFO ruff:main ruff_server::edit::notebook: After update: [ NotebookCell { document: TextDocument { contents: "y = 1", }, }, NotebookCell { document: TextDocument { contents: "class Foo:\n def __init__(self):\n self.x = 1\n\n def __str__(self):\n return f\"Foo({self.x})\"", }, }, NotebookCell { document: TextDocument { contents: "def hello():\n print(\"hello world\")", }, }, ] ``` After the fix in this PR, it can be seen that the cells are being pushed at the correct `start` index: ``` 6.520570917s INFO ruff:main ruff_server::edit::notebook: Before update: [ NotebookCell { document: TextDocument { contents: "class Foo:\n def __init__(self):\n self.x = 1\n\n def __str__(self):\n return f\"Foo({self.x})\"", }, }, NotebookCell { document: TextDocument { contents: "def hello():\n print(\"hello world\")", }, }, NotebookCell { document: TextDocument { contents: "y = 1", }, }, ] 6.521084792s INFO ruff:main ruff_server::edit::notebook: After update: [ NotebookCell { document: TextDocument { contents: "def hello():\n print(\"hello world\")", }, }, NotebookCell { document: TextDocument { contents: "class Foo:\n def __init__(self):\n self.x = 1\n\n def __str__(self):\n return f\"Foo({self.x})\"", }, }, NotebookCell { document: TextDocument { contents: "y = 1", }, }, ] ```
Configuration menu - View commit details
-
Copy full SHA for 6e9ff44 - Browse repository at this point
Copy the full SHA 6e9ff44View commit details -
Fix outdated doc for handling the default file types with the pre-com…
…mit hook (#15401) Co-authored-by: Antoine DECHAUME <>
Configuration menu - View commit details
-
Copy full SHA for 73d424e - Browse repository at this point
Copy the full SHA 73d424eView commit details -
[
flake8-pie
] Correctly remove wrapping parentheses (PIE800
) (#15394)Co-authored-by: Micha Reiser <micha@reiser.io>
Configuration menu - View commit details
-
Copy full SHA for c364b58 - Browse repository at this point
Copy the full SHA c364b58View commit details -
[red-knot] Move tuple-containing-Never tests to Markdown (#15402)
## Summary See title. Part of #15397 ## Test Plan Ran new Markdown test. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Configuration menu - View commit details
-
Copy full SHA for c874638 - Browse repository at this point
Copy the full SHA c874638View commit details -
[red-knot] Support
assert_type
(#15194)## Summary See #15103. ## Test Plan Markdown tests and unit tests.
Configuration menu - View commit details
-
Copy full SHA for 6b98a26 - Browse repository at this point
Copy the full SHA 6b98a26View commit details -
## Summary The recent release of Pygments ([2.19.1](https://github.com/pygments/pygments/releases/tag/2.19.1)) allows the pinned version to be removed as the PYI alias for Python syntax highlighting has been removed. ## Test Plan - Follow the steps outlined in https://github.com/astral-sh/ruff/blob/main/CONTRIBUTING.md#mkdocs to get the documentation site running locally. - Spot test rules pages that have PYI code blocks to ensure that syntax highlighting remains e.g. [http://127.0.0.1:8000/ruff/rules/complex-if-statement-in-stub/](http://127.0.0.1:8000/ruff/rules/complex-if-statement-in-stub/). **Note:** I am unable to test the insiders build but would assume that it functions locally as I do not have access to MkDocs Insiders, but I would like to assume that it functions in the same way as the non-insiders build.
Configuration menu - View commit details
-
Copy full SHA for adca7bd - Browse repository at this point
Copy the full SHA adca7bdView commit details -
Associate a trailing end-of-line comment in a parenthesized implicit …
…concatenated string with the last literal (#15378)
Configuration menu - View commit details
-
Copy full SHA for 2b28d56 - Browse repository at this point
Copy the full SHA 2b28d56View commit details -
Configuration menu - View commit details
-
Copy full SHA for 12f86f3 - Browse repository at this point
Copy the full SHA 12f86f3View 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 refs/tags/0.9.0...0.9.1