Skip to content

Commit a15508f

Browse files
committed
Merge branch 'main' into dcreager/smoosh-reachability
* main: (25 commits) [ty] Sync vendored typeshed stubs (#19461) [ty] Extend tuple `__len__` and `__bool__` special casing to also cover tuple subclasses (#19289) [ty] bump docstring-adder pin (#19458) [ty] Disallow assignment to `Final` class attributes (#19457) Update dependency ruff to v0.12.4 (#19442) Update pre-commit hook astral-sh/ruff-pre-commit to v0.12.4 (#19443) Update rui314/setup-mold digest to 702b190 (#19441) Update taiki-e/install-action action to v2.56.19 (#19448) Update Rust crate strum_macros to v0.27.2 (#19447) Update Rust crate strum to v0.27.2 (#19446) Update Rust crate rand to v0.9.2 (#19444) Update Rust crate serde_json to v1.0.141 (#19445) Fix `unreachable` panic in parser (#19183) [`ruff`] Support byte strings (`RUF055`) (#18926) [ty] Avoid second lookup for `infer_maybe_standalone_expression` (#19439) [ty] Implemented "go to definition" support for import statements (#19428) [ty] Avoid secondary tree traversal to get call expression for keyword arguments (#19429) [ty] Add goto definition to playground (#19425) [ty] Add support for `@warnings.deprecated` (#19376) [ty] make `del x` force local resolution of `x` in the current scope (#19389) ...
2 parents 72a2d82 + 3785e13 commit a15508f

File tree

683 files changed

+5043
-2720
lines changed

Some content is hidden

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

683 files changed

+5043
-2720
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ jobs:
238238
- name: "Install Rust toolchain"
239239
run: rustup show
240240
- name: "Install mold"
241-
uses: rui314/setup-mold@85c79d00377f0d32cdbae595a46de6f7c2fa6599 # v1
241+
uses: rui314/setup-mold@702b1908b5edf30d71a8d1666b724e0f0c6fa035 # v1
242242
- name: "Install cargo nextest"
243-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
243+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
244244
with:
245245
tool: cargo-nextest
246246
- name: "Install cargo insta"
247-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
247+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
248248
with:
249249
tool: cargo-insta
250250
- name: ty mdtests (GitHub annotations)
@@ -296,13 +296,13 @@ jobs:
296296
- name: "Install Rust toolchain"
297297
run: rustup show
298298
- name: "Install mold"
299-
uses: rui314/setup-mold@85c79d00377f0d32cdbae595a46de6f7c2fa6599 # v1
299+
uses: rui314/setup-mold@702b1908b5edf30d71a8d1666b724e0f0c6fa035 # v1
300300
- name: "Install cargo nextest"
301-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
301+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
302302
with:
303303
tool: cargo-nextest
304304
- name: "Install cargo insta"
305-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
305+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
306306
with:
307307
tool: cargo-insta
308308
- name: "Run tests"
@@ -325,7 +325,7 @@ jobs:
325325
- name: "Install Rust toolchain"
326326
run: rustup show
327327
- name: "Install cargo nextest"
328-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
328+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
329329
with:
330330
tool: cargo-nextest
331331
- name: "Run tests"
@@ -381,7 +381,7 @@ jobs:
381381
- name: "Install Rust toolchain"
382382
run: rustup show
383383
- name: "Install mold"
384-
uses: rui314/setup-mold@85c79d00377f0d32cdbae595a46de6f7c2fa6599 # v1
384+
uses: rui314/setup-mold@702b1908b5edf30d71a8d1666b724e0f0c6fa035 # v1
385385
- name: "Build"
386386
run: cargo build --release --locked
387387

@@ -406,7 +406,7 @@ jobs:
406406
MSRV: ${{ steps.msrv.outputs.value }}
407407
run: rustup default "${MSRV}"
408408
- name: "Install mold"
409-
uses: rui314/setup-mold@85c79d00377f0d32cdbae595a46de6f7c2fa6599 # v1
409+
uses: rui314/setup-mold@702b1908b5edf30d71a8d1666b724e0f0c6fa035 # v1
410410
- name: "Build tests"
411411
shell: bash
412412
env:
@@ -903,7 +903,7 @@ jobs:
903903
run: rustup show
904904

905905
- name: "Install codspeed"
906-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
906+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
907907
with:
908908
tool: cargo-codspeed
909909

@@ -936,7 +936,7 @@ jobs:
936936
run: rustup show
937937

938938
- name: "Install codspeed"
939-
uses: taiki-e/install-action@c07504cae06f832dc8de08911c9a9c5cddb0d2d3 # v2.56.13
939+
uses: taiki-e/install-action@c99cc51b309eee71a866715cfa08c922f11cf898 # v2.56.19
940940
with:
941941
tool: cargo-codspeed
942942

.github/workflows/daily_fuzz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: "Install Rust toolchain"
3939
run: rustup show
4040
- name: "Install mold"
41-
uses: rui314/setup-mold@85c79d00377f0d32cdbae595a46de6f7c2fa6599 # v1
41+
uses: rui314/setup-mold@702b1908b5edf30d71a8d1666b724e0f0c6fa035 # v1
4242
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
4343
- name: Build ruff
4444
# A debug build means the script runs slower once it gets started,

.github/workflows/sync_typeshed.yaml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ env:
3434
# and which all three workers push to.
3535
UPSTREAM_BRANCH: typeshedbot/sync-typeshed
3636

37+
# The path to the directory that contains the vendored typeshed stubs,
38+
# relative to the root of the Ruff repository.
39+
VENDORED_TYPESHED: crates/ty_vendored/vendor/typeshed
40+
3741
jobs:
3842
# Sync typeshed stubs, and sync all docstrings available on Linux.
3943
# Push the changes to a new branch on the upstream repository.
@@ -64,20 +68,20 @@ jobs:
6468
- uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
6569
- name: Sync typeshed stubs
6670
run: |
67-
rm -rf ruff/crates/ty_vendored/vendor/typeshed
68-
mkdir ruff/crates/ty_vendored/vendor/typeshed
69-
cp typeshed/README.md ruff/crates/ty_vendored/vendor/typeshed
70-
cp typeshed/LICENSE ruff/crates/ty_vendored/vendor/typeshed
71+
rm -rf "ruff/${VENDORED_TYPESHED}"
72+
mkdir "ruff/${VENDORED_TYPESHED}"
73+
cp typeshed/README.md "ruff/${VENDORED_TYPESHED}"
74+
cp typeshed/LICENSE "ruff/${VENDORED_TYPESHED}"
7175
7276
# The pyproject.toml file is needed by a later job for the black configuration.
7377
# It's deleted before creating the PR.
74-
cp typeshed/pyproject.toml ruff/crates/ty_vendored/vendor/typeshed
78+
cp typeshed/pyproject.toml "ruff/${VENDORED_TYPESHED}"
7579
76-
cp -r typeshed/stdlib ruff/crates/ty_vendored/vendor/typeshed/stdlib
77-
rm -rf ruff/crates/ty_vendored/vendor/typeshed/stdlib/@tests
78-
git -C typeshed rev-parse HEAD > ruff/crates/ty_vendored/vendor/typeshed/source_commit.txt
80+
cp -r typeshed/stdlib "ruff/${VENDORED_TYPESHED}/stdlib"
81+
rm -rf "ruff/${VENDORED_TYPESHED}/stdlib/@tests"
82+
git -C typeshed rev-parse HEAD > "ruff/${VENDORED_TYPESHED}/source_commit.txt"
7983
cd ruff
80-
git checkout -b typeshedbot/sync-typeshed
84+
git checkout -b "${UPSTREAM_BRANCH}"
8185
git add .
8286
git commit -m "Sync typeshed. Source commit: https://github.com/python/typeshed/commit/$(git -C ../typeshed rev-parse HEAD)" --allow-empty
8387
- name: Sync Linux docstrings
@@ -167,17 +171,17 @@ jobs:
167171
# consistent with the other typeshed stubs around them.
168172
# Typeshed formats code using black in their CI, so we just invoke
169173
# black on the stubs the same way that typeshed does.
170-
uvx black crates/ty_vendored/vendor/typeshed/stdlib --config crates/ty_vendored/vendor/typeshed/pyproject.toml || true
174+
uvx black "${VENDORED_TYPESHED}/stdlib" --config "${VENDORED_TYPESHED}/pyproject.toml" || true
171175
git commit -am "Format codemodded docstrings" --allow-empty
172176
173-
rm crates/ty_vendored/vendor/typeshed/pyproject.toml
177+
rm "${VENDORED_TYPESHED}/pyproject.toml"
174178
git commit -am "Remove pyproject.toml file"
175179
176180
git push
177181
- name: Create a PR
178182
if: ${{ success() }}
179183
run: |
180-
gh pr list --repo "$GITHUB_REPOSITORY" --head typeshedbot/sync-typeshed --json id --jq length | grep 1 && exit 0 # exit if there is existing pr
184+
gh pr list --repo "${GITHUB_REPOSITORY}" --head "${UPSTREAM_BRANCH}" --json id --jq length | grep 1 && exit 0 # exit if there is existing pr
181185
gh pr create --title "[ty] Sync vendored typeshed stubs" --body "Close and reopen this PR to trigger CI" --label "ty"
182186
183187
create-issue-on-failure:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ repos:
8181
pass_filenames: false # This makes it a lot faster
8282

8383
- repo: https://github.com/astral-sh/ruff-pre-commit
84-
rev: v0.12.3
84+
rev: v0.12.4
8585
hooks:
8686
- id: ruff-format
8787
- id: ruff

Cargo.lock

Lines changed: 23 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ regex-automata = { version = "0.4.9" }
139139
rustc-hash = { version = "2.0.0" }
140140
rustc-stable-hash = { version = "0.1.2" }
141141
# When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml`
142-
salsa = { git = "https://github.com/salsa-rs/salsa", rev = "fc00eba89e5dcaa5edba51c41aa5f309b5cb126b" }
142+
salsa = { git = "https://github.com/salsa-rs/salsa", rev = "dba66f1a37acca014c2402f231ed5b361bd7d8fe" }
143143
schemars = { version = "0.8.16" }
144144
seahash = { version = "4.1.0" }
145145
serde = { version = "1.0.197", features = ["derive"] }
@@ -151,7 +151,7 @@ serde_with = { version = "3.6.0", default-features = false, features = [
151151
] }
152152
shellexpand = { version = "3.0.0" }
153153
similar = { version = "2.4.0", features = ["inline"] }
154-
smallvec = { version = "1.13.2" }
154+
smallvec = { version = "1.13.2", features = ["union", "const_generics", "const_new"] }
155155
snapbox = { version = "0.6.0", features = [
156156
"diff",
157157
"term-svg",

crates/ruff_benchmark/benches/ty.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ruff_python_ast::PythonVersion;
1818
use ty_project::metadata::options::{EnvironmentOptions, Options};
1919
use ty_project::metadata::value::{RangedValue, RelativePathBuf};
2020
use ty_project::watch::{ChangeEvent, ChangedKind};
21-
use ty_project::{Db, ProjectDatabase, ProjectMetadata};
21+
use ty_project::{CheckMode, Db, ProjectDatabase, ProjectMetadata};
2222

2323
struct Case {
2424
db: ProjectDatabase,
@@ -102,6 +102,7 @@ fn setup_tomllib_case() -> Case {
102102

103103
let re = re.unwrap();
104104

105+
db.set_check_mode(CheckMode::OpenFiles);
105106
db.project().set_open_files(&mut db, tomllib_files);
106107

107108
let re_path = re.path(&db).as_system_path().unwrap().to_owned();
@@ -237,6 +238,7 @@ fn setup_micro_case(code: &str) -> Case {
237238
let mut db = ProjectDatabase::new(metadata, system).unwrap();
238239
let file = system_path_to_file(&db, SystemPathBuf::from(file_path)).unwrap();
239240

241+
db.set_check_mode(CheckMode::OpenFiles);
240242
db.project()
241243
.set_open_files(&mut db, FxHashSet::from_iter([file]));
242244

@@ -525,14 +527,21 @@ impl<'a> ProjectBenchmark<'a> {
525527

526528
#[track_caller]
527529
fn bench_project(benchmark: &ProjectBenchmark, criterion: &mut Criterion) {
528-
fn check_project(db: &mut ProjectDatabase, max_diagnostics: usize) {
530+
fn check_project(db: &mut ProjectDatabase, project_name: &str, max_diagnostics: usize) {
529531
let result = db.check();
530532
let diagnostics = result.len();
531533

532-
assert!(
533-
diagnostics <= max_diagnostics,
534-
"Expected <={max_diagnostics} diagnostics but got {diagnostics}"
535-
);
534+
if diagnostics > max_diagnostics {
535+
let details = result
536+
.into_iter()
537+
.map(|diagnostic| diagnostic.concise_message().to_string())
538+
.collect::<Vec<_>>()
539+
.join("\n ");
540+
assert!(
541+
diagnostics <= max_diagnostics,
542+
"{project_name}: Expected <={max_diagnostics} diagnostics but got {diagnostics}:\n {details}",
543+
);
544+
}
536545
}
537546

538547
setup_rayon();
@@ -542,7 +551,7 @@ fn bench_project(benchmark: &ProjectBenchmark, criterion: &mut Criterion) {
542551
group.bench_function(benchmark.project.config.name, |b| {
543552
b.iter_batched_ref(
544553
|| benchmark.setup_iteration(),
545-
|db| check_project(db, benchmark.max_diagnostics),
554+
|db| check_project(db, benchmark.project.config.name, benchmark.max_diagnostics),
546555
BatchSize::SmallInput,
547556
);
548557
});
@@ -610,7 +619,7 @@ fn datetype(criterion: &mut Criterion) {
610619
max_dep_date: "2025-07-04",
611620
python_version: PythonVersion::PY313,
612621
},
613-
0,
622+
2,
614623
);
615624

616625
bench_project(&benchmark, criterion);

0 commit comments

Comments
 (0)