Skip to content

Commit be9749c

Browse files
committed
Merge remote-tracking branch 'origin/main' into dcreager/new-relation
* origin/main: Respect `--output-format` with `--watch` (#21097) [`pyflakes`] Revert to stable behavior if imports for module lie in alternate branches for `F401` (#20878) Fix finding keyword range for clause header after statement ending with semicolon (#21067) [ty] Fix bug where ty would think all types had an `__mro__` attribute (#20995) Restore `indent.py` (#21094) [`flake8-django`] Apply `DJ001` to annotated fields (#20907) Clearer error message when `line-length` goes beyond threshold (#21072) Update upload and download artifacts github actions (#21083) Update dependency mdformat-mkdocs to v4.4.2 (#21088) Update cargo-bins/cargo-binstall action to v1.15.9 (#21086) Update Rust crate clap to v4.5.50 (#21090) Update Rust crate get-size2 to v0.7.1 (#21091) Update Rust crate bstr to v1.12.1 (#21089) Add missing docstring sections to the numpy list (#20931) [`pydoclint`] Fix false positive on explicit exception re-raising (`DOC501`, `DOC502`) (#21011) [ty] Use constructor parameter types as type context (#21054)
2 parents 0395ae9 + 96b60c1 commit be9749c

File tree

66 files changed

+1917
-721
lines changed

Some content is hidden

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

66 files changed

+1917
-721
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ jobs:
438438
- name: "Install Rust toolchain"
439439
run: rustup show
440440
- name: "Install cargo-binstall"
441-
uses: cargo-bins/cargo-binstall@a66119fbb1c952daba62640c2609111fe0803621 # v1.15.7
441+
uses: cargo-bins/cargo-binstall@afcf9780305558bcc9e4bc94b7589ab2bb8b6106 # v1.15.9
442442
- name: "Install cargo-fuzz"
443443
# Download the latest version from quick install and not the github releases because github releases only has MUSL targets.
444444
run: cargo binstall cargo-fuzz --force --disable-strategies crate-meta-data --no-confirm
@@ -699,7 +699,7 @@ jobs:
699699
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
700700
with:
701701
persist-credentials: false
702-
- uses: cargo-bins/cargo-binstall@a66119fbb1c952daba62640c2609111fe0803621 # v1.15.7
702+
- uses: cargo-bins/cargo-binstall@afcf9780305558bcc9e4bc94b7589ab2bb8b6106 # v1.15.9
703703
- run: cargo binstall --no-confirm cargo-shear
704704
- run: cargo shear
705705

.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
shell: bash
7171
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.0/cargo-dist-installer.sh | sh"
7272
- name: Cache dist
73-
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47
73+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
7474
with:
7575
name: cargo-dist-cache
7676
path: ~/.cargo/bin/dist
@@ -86,7 +86,7 @@ jobs:
8686
cat plan-dist-manifest.json
8787
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8888
- name: "Upload dist-manifest.json"
89-
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47
89+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
9090
with:
9191
name: artifacts-plan-dist-manifest
9292
path: plan-dist-manifest.json
@@ -128,14 +128,14 @@ jobs:
128128
persist-credentials: false
129129
submodules: recursive
130130
- name: Install cached dist
131-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
131+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
132132
with:
133133
name: cargo-dist-cache
134134
path: ~/.cargo/bin/
135135
- run: chmod +x ~/.cargo/bin/dist
136136
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
137137
- name: Fetch local artifacts
138-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
138+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
139139
with:
140140
pattern: artifacts-*
141141
path: target/distrib/
@@ -153,7 +153,7 @@ jobs:
153153
154154
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
155155
- name: "Upload artifacts"
156-
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47
156+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
157157
with:
158158
name: artifacts-build-global
159159
path: |
@@ -179,14 +179,14 @@ jobs:
179179
persist-credentials: false
180180
submodules: recursive
181181
- name: Install cached dist
182-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
182+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
183183
with:
184184
name: cargo-dist-cache
185185
path: ~/.cargo/bin/
186186
- run: chmod +x ~/.cargo/bin/dist
187187
# Fetch artifacts from scratch-storage
188188
- name: Fetch artifacts
189-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
189+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
190190
with:
191191
pattern: artifacts-*
192192
path: target/distrib/
@@ -200,7 +200,7 @@ jobs:
200200
cat dist-manifest.json
201201
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
202202
- name: "Upload dist-manifest.json"
203-
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47
203+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
204204
with:
205205
# Overwrite the previous copy
206206
name: artifacts-dist-manifest
@@ -256,7 +256,7 @@ jobs:
256256
submodules: recursive
257257
# Create a GitHub Release while uploading all files to it
258258
- name: "Download GitHub Artifacts"
259-
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
259+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
260260
with:
261261
pattern: artifacts-*
262262
path: artifacts

Cargo.lock

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

crates/ruff/src/printer.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ use itertools::{Itertools, iterate};
99
use ruff_linter::linter::FixTable;
1010
use serde::Serialize;
1111

12-
use ruff_db::diagnostic::{
13-
Diagnostic, DiagnosticFormat, DisplayDiagnosticConfig, DisplayDiagnostics, SecondaryCode,
14-
};
12+
use ruff_db::diagnostic::{Diagnostic, DisplayDiagnosticConfig, SecondaryCode};
1513
use ruff_linter::fs::relativize_path;
1614
use ruff_linter::logging::LogLevel;
1715
use ruff_linter::message::{EmitterContext, render_diagnostics};
@@ -390,21 +388,18 @@ impl Printer {
390388

391389
let context = EmitterContext::new(&diagnostics.notebook_indexes);
392390
let format = if preview {
393-
DiagnosticFormat::Full
391+
self.format
394392
} else {
395-
DiagnosticFormat::Concise
393+
OutputFormat::Concise
396394
};
397395
let config = DisplayDiagnosticConfig::default()
396+
.preview(preview)
398397
.hide_severity(true)
399398
.color(!cfg!(test) && colored::control::SHOULD_COLORIZE.should_colorize())
400399
.with_show_fix_status(show_fix_status(self.fix_mode, fixables.as_ref()))
401-
.format(format)
402-
.with_fix_applicability(self.unsafe_fixes.required_applicability());
403-
write!(
404-
writer,
405-
"{}",
406-
DisplayDiagnostics::new(&context, &config, &diagnostics.inner)
407-
)?;
400+
.with_fix_applicability(self.unsafe_fixes.required_applicability())
401+
.show_fix_diff(preview);
402+
render_diagnostics(writer, format, config, &context, &diagnostics.inner)?;
408403
}
409404
writer.flush()?;
410405

crates/ruff_linter/resources/test/fixtures/flake8_django/DJ001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ class CorrectModel(models.Model):
4646
max_length=255, null=True, blank=True, unique=True
4747
)
4848
urlfieldu = models.URLField(max_length=255, null=True, blank=True, unique=True)
49+
50+
51+
class IncorrectModelWithSimpleAnnotations(models.Model):
52+
charfield: models.CharField = models.CharField(max_length=255, null=True)
53+
textfield: models.TextField = models.TextField(max_length=255, null=True)
54+
slugfield: models.SlugField = models.SlugField(max_length=255, null=True)

crates/ruff_linter/resources/test/fixtures/pydoclint/DOC102_numpy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,22 @@ async def convert(cls, ctx: Context, argument: str) -> Self:
370370
The flag converter instance with all flags parsed.
371371
"""
372372
return
373+
374+
# OK
375+
def baz(x: int) -> int:
376+
"""
377+
Show a `Warnings` DOC102 false positive.
378+
379+
Parameters
380+
----------
381+
x : int
382+
383+
Warnings
384+
--------
385+
This function demonstrates a DOC102 false positive
386+
387+
Returns
388+
-------
389+
int
390+
"""
391+
return x

crates/ruff_linter/resources/test/fixtures/pydoclint/DOC502_google.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,55 @@ def calculate_speed(distance: float, time: float) -> float:
8181
except TypeError:
8282
print("Not a number? Shame on you!")
8383
raise
84+
85+
86+
# This should NOT trigger DOC502 because OSError is explicitly re-raised
87+
def f():
88+
"""Do nothing.
89+
90+
Raises:
91+
OSError: If the OS errors.
92+
"""
93+
try:
94+
pass
95+
except OSError as e:
96+
raise e
97+
98+
99+
# This should NOT trigger DOC502 because OSError is explicitly re-raised with from None
100+
def g():
101+
"""Do nothing.
102+
103+
Raises:
104+
OSError: If the OS errors.
105+
"""
106+
try:
107+
pass
108+
except OSError as e:
109+
raise e from None
110+
111+
112+
# This should NOT trigger DOC502 because ValueError is explicitly re-raised from tuple exception
113+
def h():
114+
"""Do nothing.
115+
116+
Raises:
117+
ValueError: If something goes wrong.
118+
"""
119+
try:
120+
pass
121+
except (ValueError, TypeError) as e:
122+
raise e
123+
124+
125+
# This should NOT trigger DOC502 because TypeError is explicitly re-raised from tuple exception
126+
def i():
127+
"""Do nothing.
128+
129+
Raises:
130+
TypeError: If something goes wrong.
131+
"""
132+
try:
133+
pass
134+
except (ValueError, TypeError) as e:
135+
raise e

crates/ruff_linter/src/docstrings/google.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub(crate) static GOOGLE_SECTIONS: &[SectionKind] = &[
1111
SectionKind::References,
1212
SectionKind::Returns,
1313
SectionKind::SeeAlso,
14+
SectionKind::Warnings,
15+
SectionKind::Warns,
1416
SectionKind::Yields,
1517
// Google-only
1618
SectionKind::Args,
@@ -32,7 +34,5 @@ pub(crate) static GOOGLE_SECTIONS: &[SectionKind] = &[
3234
SectionKind::Tip,
3335
SectionKind::Todo,
3436
SectionKind::Warning,
35-
SectionKind::Warnings,
36-
SectionKind::Warns,
3737
SectionKind::Yield,
3838
];

crates/ruff_linter/src/docstrings/numpy.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ pub(crate) static NUMPY_SECTIONS: &[SectionKind] = &[
1111
SectionKind::References,
1212
SectionKind::Returns,
1313
SectionKind::SeeAlso,
14+
SectionKind::Warnings,
15+
SectionKind::Warns,
1416
SectionKind::Yields,
1517
// NumPy-only
1618
SectionKind::ExtendedSummary,
1719
SectionKind::OtherParams,
1820
SectionKind::OtherParameters,
1921
SectionKind::Parameters,
22+
SectionKind::Receives,
2023
SectionKind::ShortSummary,
2124
];

0 commit comments

Comments
 (0)