Skip to content

Commit 68fc51c

Browse files
committed
Merge remote-tracking branch 'origin/main' into dcreager/non-non-inferable
* origin/main: [ty] Add (unused) `inferable` parameter to type property methods (#20865) Run macos tests on macos (#20889) Remove `release` CI job (#20887) [ty] CI: Faster ecosystem analysis (#20886) Remove `strip` from release profile (#20885) [ty] Sync vendored typeshed stubs (#20876) [ty] Add some completion ranking improvements (#20807) Improved error recovery for unclosed strings (including f- and t-strings) (#20848) Enable lto=fat (#20863) [`pyupgrade`] Extend `UP019` to detect `typing_extensions.Text` (`UP019`) (#20825) [`flake8-bugbear`] Omit annotation in preview fix for `B006` (#20877) fix(docs): Fix typo in `RUF015` description (#20873) [ty] Improve and extend tests for instance attributes redeclared in subclasses (#20866) [ty] Ignore slow seeds as a temporary measure (#20870) Remove parentheses around multiple exception types on Python 3.14+ (#20768) Update Black tests (#20794)
2 parents 43da7c7 + 8817ea5 commit 68fc51c

File tree

341 files changed

+9575
-1375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+9575
-1375
lines changed

.github/workflows/ci.yaml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
env:
143143
MERGE_BASE: ${{ steps.merge_base.outputs.sha }}
144144
run: |
145-
if git diff --quiet "${MERGE_BASE}...HEAD" -- 'python/py_fuzzer/**' \
145+
if git diff --quiet "${MERGE_BASE}...HEAD" -- 'python/py-fuzzer/**' \
146146
; then
147147
echo "changed=false" >> "$GITHUB_OUTPUT"
148148
else
@@ -361,6 +361,37 @@ jobs:
361361
cargo nextest run --all-features --profile ci
362362
cargo test --all-features --doc
363363
364+
cargo-test-macos:
365+
name: "cargo test (macos)"
366+
runs-on: macos-latest
367+
needs: determine_changes
368+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
369+
timeout-minutes: 20
370+
steps:
371+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
372+
with:
373+
persist-credentials: false
374+
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
375+
- name: "Install Rust toolchain"
376+
run: rustup show
377+
- name: "Install mold"
378+
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
379+
- name: "Install cargo nextest"
380+
uses: taiki-e/install-action@522492a8c115f1b6d4d318581f09638e9442547b # v2.62.21
381+
with:
382+
tool: cargo-nextest
383+
- name: "Install uv"
384+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
385+
with:
386+
enable-cache: "true"
387+
- name: "Run tests"
388+
shell: bash
389+
env:
390+
NEXTEST_PROFILE: "ci"
391+
run: |
392+
cargo nextest run --all-features --profile ci
393+
cargo test --all-features --doc
394+
364395
cargo-test-wasm:
365396
name: "cargo test (wasm)"
366397
runs-on: ubuntu-latest
@@ -391,23 +422,6 @@ jobs:
391422
cd crates/ty_wasm
392423
wasm-pack test --node
393424
394-
cargo-build-release:
395-
name: "cargo build (release)"
396-
runs-on: macos-latest
397-
if: ${{ github.ref == 'refs/heads/main' }}
398-
timeout-minutes: 20
399-
steps:
400-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
401-
with:
402-
persist-credentials: false
403-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
404-
- name: "Install Rust toolchain"
405-
run: rustup show
406-
- name: "Install mold"
407-
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
408-
- name: "Build"
409-
run: cargo build --release --locked
410-
411425
cargo-build-msrv:
412426
name: "cargo build (msrv)"
413427
runs-on: depot-ubuntu-latest-8
@@ -721,7 +735,7 @@ jobs:
721735
- name: "Install Rust toolchain"
722736
run: rustup show
723737
- name: "Run ty completion evaluation"
724-
run: cargo run --release --package ty_completion_eval -- all --threshold 0.1 --tasks /tmp/completion-evaluation-tasks.csv
738+
run: cargo run --release --package ty_completion_eval -- all --threshold 0.4 --tasks /tmp/completion-evaluation-tasks.csv
725739
- name: "Ensure there are no changes"
726740
run: diff ./crates/ty_completion_eval/completion-evaluation-tasks.csv /tmp/completion-evaluation-tasks.csv
727741

.github/workflows/ty-ecosystem-analyzer.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ jobs:
6464
6565
cd ..
6666
67-
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@279f8a15b0e7f77213bf9096dbc2335a19ef89c5"
67+
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@908758da02a73ef3f3308e1dbb2248510029bbe4"
6868
6969
ecosystem-analyzer \
7070
--repository ruff \
7171
diff \
72-
--profile=release \
72+
--profile=profiling \
7373
--projects-old ruff/projects_old.txt \
7474
--projects-new ruff/projects_new.txt \
7575
--old old_commit \

.github/workflows/ty-ecosystem-report.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ jobs:
4949
5050
cd ..
5151
52-
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@279f8a15b0e7f77213bf9096dbc2335a19ef89c5"
52+
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@908758da02a73ef3f3308e1dbb2248510029bbe4"
5353
5454
ecosystem-analyzer \
5555
--verbose \
5656
--repository ruff \
5757
analyze \
58-
--profile=release \
58+
--profile=profiling \
5959
--projects ruff/crates/ty_python_semantic/resources/primer/good.txt \
6060
--output ecosystem-diagnostics.json
6161

Cargo.toml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,7 @@ large_stack_arrays = "allow"
268268

269269

270270
[profile.release]
271-
# Note that we set these explicitly, and these values
272-
# were chosen based on a trade-off between compile times
273-
# and runtime performance[1].
274-
#
275-
# [1]: https://github.com/astral-sh/ruff/pull/9031
276-
lto = "thin"
271+
lto = "fat"
277272
codegen-units = 16
278273

279274
# Some crates don't change as much but benefit more from
@@ -283,6 +278,8 @@ codegen-units = 16
283278
codegen-units = 1
284279
[profile.release.package.ruff_python_ast]
285280
codegen-units = 1
281+
[profile.release.package.salsa]
282+
codegen-units = 1
286283

287284
[profile.dev.package.insta]
288285
opt-level = 3
@@ -298,11 +295,30 @@ opt-level = 3
298295
[profile.dev.package.ruff_python_parser]
299296
opt-level = 1
300297

298+
# This profile is meant to mimic the `release` profile as closely as
299+
# possible, but using settings that are more beneficial for iterative
300+
# development. That is, the `release` profile is intended for actually
301+
# building the release, where as `profiling` is meant for building ty/ruff
302+
# for running benchmarks.
303+
#
304+
# The main differences here are to avoid stripping debug information
305+
# and disabling fat lto. This does result in a mismatch between our release
306+
# configuration and our benchmarking configuration, which is unfortunate.
307+
# But compile times with `lto = fat` are completely untenable.
308+
#
309+
# This setup does risk that we are measuring something in benchmarks
310+
# that we aren't shipping, but in order to make those two the same, we'd
311+
# either need to make compile times way worse for development, or take
312+
# a hit to binary size and a slight hit to runtime performance in our
313+
# release builds.
314+
#
301315
# Use the `--profile profiling` flag to show symbols in release mode.
302316
# e.g. `cargo build --profile profiling`
303317
[profile.profiling]
304318
inherits = "release"
305-
debug = 1
319+
strip = false
320+
debug = "full"
321+
lto = false
306322

307323
# The profile that 'cargo dist' will build with.
308324
[profile.dist]

crates/ruff_linter/resources/test/fixtures/flake8_implicit_str_concat/ISC_syntax_error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# The lexer doesn't emit a string token if it's unterminated
1+
# The lexer emits a string token if it's unterminated
22
"a" "b
33
"a" "b" "c
44
"a" """b
55
c""" "d
66

7-
# For f-strings, the `FStringRanges` won't contain the range for
7+
# This is also true for
88
# unterminated f-strings.
99
f"a" f"b
1010
f"a" f"b" f"c

crates/ruff_linter/resources/test/fixtures/pyupgrade/UP019.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,20 @@ def print_third_word(word: Hello.Text) -> None:
1818

1919
def print_fourth_word(word: Goodbye) -> None:
2020
print(word)
21+
22+
23+
import typing_extensions
24+
import typing_extensions as TypingExt
25+
from typing_extensions import Text as TextAlias
26+
27+
28+
def print_fifth_word(word: typing_extensions.Text) -> None:
29+
print(word)
30+
31+
32+
def print_sixth_word(word: TypingExt.Text) -> None:
33+
print(word)
34+
35+
36+
def print_seventh_word(word: TextAlias) -> None:
37+
print(word)

crates/ruff_linter/src/preview.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,7 @@ pub(crate) const fn is_fix_read_whole_file_enabled(settings: &LinterSettings) ->
265265
pub(crate) const fn is_fix_write_whole_file_enabled(settings: &LinterSettings) -> bool {
266266
settings.preview.is_enabled()
267267
}
268+
269+
pub(crate) const fn is_typing_extensions_str_alias_enabled(settings: &LinterSettings) -> bool {
270+
settings.preview.is_enabled()
271+
}

crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,10 @@ fn move_initialization(
188188
content.push_str(stylist.line_ending().as_str());
189189
content.push_str(stylist.indentation());
190190
if is_b006_unsafe_fix_preserve_assignment_expr_enabled(checker.settings()) {
191-
let annotation = if let Some(ann) = parameter.annotation() {
192-
format!(": {}", locator.slice(ann))
193-
} else {
194-
String::new()
195-
};
196191
let _ = write!(
197192
&mut content,
198-
"{}{} = {}",
193+
"{} = {}",
199194
parameter.parameter.name(),
200-
annotation,
201195
locator.slice(
202196
parenthesized_range(
203197
default.into(),

crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B006_B006_5.py.snap

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ help: Replace with `None`; initialize within function
1616
5 + def import_module_wrong(value: dict[str, str] = None):
1717
6 | import os
1818
7 + if value is None:
19-
8 + value: dict[str, str] = {}
19+
8 + value = {}
2020
9 |
2121
10 |
2222
11 | def import_module_with_values_wrong(value: dict[str, str] = {}):
@@ -38,7 +38,7 @@ help: Replace with `None`; initialize within function
3838
10 | import os
3939
11 |
4040
12 + if value is None:
41-
13 + value: dict[str, str] = {}
41+
13 + value = {}
4242
14 | return 2
4343
15 |
4444
16 |
@@ -62,7 +62,7 @@ help: Replace with `None`; initialize within function
6262
17 | import sys
6363
18 | import itertools
6464
19 + if value is None:
65-
20 + value: dict[str, str] = {}
65+
20 + value = {}
6666
21 |
6767
22 |
6868
23 | def from_import_module_wrong(value: dict[str, str] = {}):
@@ -83,7 +83,7 @@ help: Replace with `None`; initialize within function
8383
21 + def from_import_module_wrong(value: dict[str, str] = None):
8484
22 | from os import path
8585
23 + if value is None:
86-
24 + value: dict[str, str] = {}
86+
24 + value = {}
8787
25 |
8888
26 |
8989
27 | def from_imports_module_wrong(value: dict[str, str] = {}):
@@ -106,7 +106,7 @@ help: Replace with `None`; initialize within function
106106
26 | from os import path
107107
27 | from sys import version_info
108108
28 + if value is None:
109-
29 + value: dict[str, str] = {}
109+
29 + value = {}
110110
30 |
111111
31 |
112112
32 | def import_and_from_imports_module_wrong(value: dict[str, str] = {}):
@@ -129,7 +129,7 @@ help: Replace with `None`; initialize within function
129129
31 | import os
130130
32 | from sys import version_info
131131
33 + if value is None:
132-
34 + value: dict[str, str] = {}
132+
34 + value = {}
133133
35 |
134134
36 |
135135
37 | def import_docstring_module_wrong(value: dict[str, str] = {}):
@@ -152,7 +152,7 @@ help: Replace with `None`; initialize within function
152152
36 | """Docstring"""
153153
37 | import os
154154
38 + if value is None:
155-
39 + value: dict[str, str] = {}
155+
39 + value = {}
156156
40 |
157157
41 |
158158
42 | def import_module_wrong(value: dict[str, str] = {}):
@@ -175,7 +175,7 @@ help: Replace with `None`; initialize within function
175175
41 | """Docstring"""
176176
42 | import os; import sys
177177
43 + if value is None:
178-
44 + value: dict[str, str] = {}
178+
44 + value = {}
179179
45 |
180180
46 |
181181
47 | def import_module_wrong(value: dict[str, str] = {}):
@@ -197,7 +197,7 @@ help: Replace with `None`; initialize within function
197197
45 + def import_module_wrong(value: dict[str, str] = None):
198198
46 | """Docstring"""
199199
47 + if value is None:
200-
48 + value: dict[str, str] = {}
200+
48 + value = {}
201201
49 | import os; import sys; x = 1
202202
50 |
203203
51 |
@@ -220,7 +220,7 @@ help: Replace with `None`; initialize within function
220220
51 | """Docstring"""
221221
52 | import os; import sys
222222
53 + if value is None:
223-
54 + value: dict[str, str] = {}
223+
54 + value = {}
224224
55 |
225225
56 |
226226
57 | def import_module_wrong(value: dict[str, str] = {}):
@@ -241,7 +241,7 @@ help: Replace with `None`; initialize within function
241241
55 + def import_module_wrong(value: dict[str, str] = None):
242242
56 | import os; import sys
243243
57 + if value is None:
244-
58 + value: dict[str, str] = {}
244+
58 + value = {}
245245
59 |
246246
60 |
247247
61 | def import_module_wrong(value: dict[str, str] = {}):
@@ -261,7 +261,7 @@ help: Replace with `None`; initialize within function
261261
- def import_module_wrong(value: dict[str, str] = {}):
262262
59 + def import_module_wrong(value: dict[str, str] = None):
263263
60 + if value is None:
264-
61 + value: dict[str, str] = {}
264+
61 + value = {}
265265
62 | import os; import sys; x = 1
266266
63 |
267267
64 |
@@ -282,7 +282,7 @@ help: Replace with `None`; initialize within function
282282
63 + def import_module_wrong(value: dict[str, str] = None):
283283
64 | import os; import sys
284284
65 + if value is None:
285-
66 + value: dict[str, str] = {}
285+
66 + value = {}
286286
67 |
287287
68 |
288288
69 | def import_module_wrong(value: dict[str, str] = {}): import os

crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B006_B006_8.py.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ help: Replace with `None`; initialize within function
5151
10 + def baz(a: list = None):
5252
11 | """This one raises a different exception"""
5353
12 + if a is None:
54-
13 + a: list = []
54+
13 + a = []
5555
14 | raise IndexError()
5656
15 |
5757
16 |

0 commit comments

Comments
 (0)