Skip to content

Commit 0f0cd47

Browse files
committed
Merge branch 'dcreager/merge-arguments' into dcreager/splat
* dcreager/merge-arguments: add types iterator add asserting constructor debug assert lengths remove unused From use FromIterator [`pylint`] Extend invalid string character rules to include t-strings (#19355) Make TC010 docs example more realistic (#19356) Move RDJSON rendering to `ruff_db` (#19293) [`flake8-use-pathlib`] Skip single dots for `invalid-pathlib-with-suffix` (`PTH210`) on versions >= 3.14 (#19331) [`ruff`] Allow `strict` kwarg when checking for `starmap-zip` (`RUF058`) in Python 3.14+ (#19333) [ty] Reduce false positives for `TypedDict` types (#19354) [ty] Remove `ConnectionInitializer` (#19353) [ty] Use `Type::string_literal()` more (#19352) [ty] Add ecosystem-report workflow (#19349) [ty] Make use of salsa `Lookup` when interning values (#19347) [ty] Sync vendored typeshed stubs (#19345) [`pylint`] Make example error out-of-the-box (`PLE2502`) (#19272) [`pydoclint`] Fix `SyntaxError` from fixes with line continuations (`D201`, `D202`) (#19246)
2 parents 06f75c4 + 9a1175c commit 0f0cd47

File tree

51 files changed

+781
-402
lines changed

Some content is hidden

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

51 files changed

+781
-402
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: ty ecosystem-report
2+
3+
permissions: {}
4+
5+
on:
6+
workflow_dispatch:
7+
schedule:
8+
# Run every Wednesday at 5:00 UTC:
9+
- cron: 0 5 * * 3
10+
11+
env:
12+
CARGO_INCREMENTAL: 0
13+
CARGO_NET_RETRY: 10
14+
CARGO_TERM_COLOR: always
15+
RUSTUP_MAX_RETRIES: 10
16+
RUST_BACKTRACE: 1
17+
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
18+
19+
jobs:
20+
ty-ecosystem-report:
21+
name: Create ecosystem report
22+
runs-on: depot-ubuntu-22.04-32
23+
timeout-minutes: 20
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
path: ruff
28+
fetch-depth: 0
29+
persist-credentials: false
30+
31+
- name: Install the latest version of uv
32+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
33+
34+
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
35+
with:
36+
workspaces: "ruff"
37+
38+
- name: Install Rust toolchain
39+
run: rustup show
40+
41+
- name: Create report
42+
shell: bash
43+
run: |
44+
cd ruff
45+
46+
echo "Enabling configuration overloads (see .github/mypy-primer-ty.toml)"
47+
mkdir -p ~/.config/ty
48+
cp .github/mypy-primer-ty.toml ~/.config/ty/ty.toml
49+
50+
cd ..
51+
52+
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@f0eec0e549684d8e1d7b8bc3e351202124b63bda"
53+
54+
ecosystem-analyzer \
55+
--verbose \
56+
--repository ruff \
57+
analyze \
58+
--projects ruff/crates/ty_python_semantic/resources/primer/good.txt \
59+
--output ecosystem-diagnostics.json
60+
61+
mkdir dist
62+
63+
ecosystem-analyzer \
64+
generate-report \
65+
--max-diagnostics-per-project=1200 \
66+
ecosystem-diagnostics.json \
67+
--output dist/index.html
68+
69+
- name: "Deploy to Cloudflare Pages"
70+
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
71+
id: deploy
72+
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
73+
with:
74+
apiToken: ${{ secrets.CF_API_TOKEN }}
75+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
76+
command: pages deploy dist --project-name=ty-ecosystem --branch main --commit-hash ${GITHUB_SHA}

.github/zizmor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rules:
1111
- build-docker.yml
1212
- publish-playground.yml
1313
- ty-ecosystem-analyzer.yaml
14+
- ty-ecosystem-report.yaml
1415
excessive-permissions:
1516
# it's hard to test what the impact of removing these ignores would be
1617
# without actually running the release workflow...

crates/ruff/src/printer.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ruff_linter::fs::relativize_path;
1616
use ruff_linter::logging::LogLevel;
1717
use ruff_linter::message::{
1818
Emitter, EmitterContext, GithubEmitter, GitlabEmitter, GroupedEmitter, JunitEmitter,
19-
PylintEmitter, RdjsonEmitter, SarifEmitter, TextEmitter,
19+
PylintEmitter, SarifEmitter, TextEmitter,
2020
};
2121
use ruff_linter::notify_user;
2222
use ruff_linter::settings::flags::{self};
@@ -238,7 +238,11 @@ impl Printer {
238238
write!(writer, "{value}")?;
239239
}
240240
OutputFormat::Rdjson => {
241-
RdjsonEmitter.emit(writer, &diagnostics.inner, &context)?;
241+
let config = DisplayDiagnosticConfig::default()
242+
.format(DiagnosticFormat::Rdjson)
243+
.preview(preview);
244+
let value = DisplayDiagnostics::new(&context, &config, &diagnostics.inner);
245+
write!(writer, "{value}")?;
242246
}
243247
OutputFormat::JsonLines => {
244248
let config = DisplayDiagnosticConfig::default()

crates/ruff/tests/snapshots/lint__output_format_rdjson.snap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ exit_code: 1
7575
},
7676
{
7777
"code": {
78-
"url": null,
79-
"value": null
78+
"value": "invalid-syntax"
8079
},
8180
"location": {
8281
"path": "[TMP]/input.py",
@@ -94,7 +93,7 @@ exit_code: 1
9493
"message": "SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)"
9594
}
9695
],
97-
"severity": "warning",
96+
"severity": "WARNING",
9897
"source": {
9998
"name": "ruff",
10099
"url": "https://docs.astral.sh/ruff"

crates/ruff_db/src/diagnostic/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ impl Diagnostic {
308308

309309
/// Set the fix for this diagnostic.
310310
pub fn set_fix(&mut self, fix: Fix) {
311+
debug_assert!(
312+
self.primary_span().is_some(),
313+
"Expected a source file for a diagnostic with a fix"
314+
);
311315
Arc::make_mut(&mut self.inner).fix = Some(fix);
312316
}
313317

@@ -1259,6 +1263,11 @@ pub enum DiagnosticFormat {
12591263
/// format for an array of all diagnostics. See <https://jsonlines.org/> for more details.
12601264
#[cfg(feature = "serde")]
12611265
JsonLines,
1266+
/// Print diagnostics in the JSON format expected by [reviewdog].
1267+
///
1268+
/// [reviewdog]: https://github.com/reviewdog/reviewdog
1269+
#[cfg(feature = "serde")]
1270+
Rdjson,
12621271
}
12631272

12641273
/// A representation of the kinds of messages inside a diagnostic.

crates/ruff_db/src/diagnostic/render.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ mod azure;
2828
mod json;
2929
#[cfg(feature = "serde")]
3030
mod json_lines;
31+
#[cfg(feature = "serde")]
32+
mod rdjson;
3133

3234
/// A type that implements `std::fmt::Display` for diagnostic rendering.
3335
///
@@ -184,6 +186,10 @@ impl std::fmt::Display for DisplayDiagnostics<'_> {
184186
json_lines::JsonLinesRenderer::new(self.resolver, self.config)
185187
.render(f, self.diagnostics)?;
186188
}
189+
#[cfg(feature = "serde")]
190+
DiagnosticFormat::Rdjson => {
191+
rdjson::RdjsonRenderer::new(self.resolver).render(f, self.diagnostics)?;
192+
}
187193
}
188194

189195
Ok(())

crates/ruff_db/src/diagnostic/render/json.rs

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,6 @@ struct JsonEdit<'a> {
262262

263263
#[cfg(test)]
264264
mod tests {
265-
use ruff_diagnostics::{Edit, Fix};
266-
use ruff_text_size::TextSize;
267-
268265
use crate::diagnostic::{
269266
DiagnosticFormat,
270267
render::tests::{
@@ -297,13 +294,7 @@ mod tests {
297294
env.format(DiagnosticFormat::Json);
298295
env.preview(false);
299296

300-
let diag = env
301-
.err()
302-
.fix(Fix::safe_edit(Edit::insertion(
303-
"edit".to_string(),
304-
TextSize::from(0),
305-
)))
306-
.build();
297+
let diag = env.err().build();
307298

308299
insta::assert_snapshot!(
309300
env.render(&diag),
@@ -317,23 +308,7 @@ mod tests {
317308
"row": 1
318309
},
319310
"filename": "",
320-
"fix": {
321-
"applicability": "safe",
322-
"edits": [
323-
{
324-
"content": "edit",
325-
"end_location": {
326-
"column": 1,
327-
"row": 1
328-
},
329-
"location": {
330-
"column": 1,
331-
"row": 1
332-
}
333-
}
334-
],
335-
"message": null
336-
},
311+
"fix": null,
337312
"location": {
338313
"column": 1,
339314
"row": 1
@@ -353,13 +328,7 @@ mod tests {
353328
env.format(DiagnosticFormat::Json);
354329
env.preview(true);
355330

356-
let diag = env
357-
.err()
358-
.fix(Fix::safe_edit(Edit::insertion(
359-
"edit".to_string(),
360-
TextSize::from(0),
361-
)))
362-
.build();
331+
let diag = env.err().build();
363332

364333
insta::assert_snapshot!(
365334
env.render(&diag),
@@ -370,17 +339,7 @@ mod tests {
370339
"code": null,
371340
"end_location": null,
372341
"filename": null,
373-
"fix": {
374-
"applicability": "safe",
375-
"edits": [
376-
{
377-
"content": "edit",
378-
"end_location": null,
379-
"location": null
380-
}
381-
],
382-
"message": null
383-
},
342+
"fix": null,
384343
"location": null,
385344
"message": "main diagnostic message",
386345
"noqa_row": null,

0 commit comments

Comments
 (0)