Skip to content

Commit 96562f0

Browse files
committed
Merge branch 'main' into dcreager/inferrable
* main: [ty] Add diagnostics for invalid `await` expressions (#19711) [ty] Synthesize read-only properties for all declared members on `NamedTuple` classes (#19899) [ty] Remove use of `ClassBase::try_from_type` from `super()` machinery (#19902) [ty] Speedup project file discovery (#19913) [`pyflakes`] Add secondary annotation showing previous definition (`F811`) (#19900) Bump 0.12.9 (#19917) [ty] support `kw_only=True` for `dataclass()` and `field()` (#19677)
2 parents 94c776c + 957320c commit 96562f0

File tree

63 files changed

+1206
-235
lines changed

Some content is hidden

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

63 files changed

+1206
-235
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# Changelog
22

3+
## 0.12.9
4+
5+
### Preview features
6+
7+
- \[`airflow`\] Add check for `airflow.secrets.cache.SecretCache` (`AIR301`) ([#17707](https://github.com/astral-sh/ruff/pull/17707))
8+
- \[`ruff`\] Offer a safe fix for multi-digit zeros (`RUF064`) ([#19847](https://github.com/astral-sh/ruff/pull/19847))
9+
10+
### Bug fixes
11+
12+
- \[`flake8-blind-except`\] Fix `BLE001` false-positive on `raise ... from None` ([#19755](https://github.com/astral-sh/ruff/pull/19755))
13+
- \[`flake8-comprehensions`\] Fix false positive for `C420` with attribute, subscript, or slice assignment targets ([#19513](https://github.com/astral-sh/ruff/pull/19513))
14+
- \[`flake8-simplify`\] Fix handling of U+001C..U+001F whitespace (`SIM905`) ([#19849](https://github.com/astral-sh/ruff/pull/19849))
15+
16+
### Rule changes
17+
18+
- \[`pylint`\] Use lowercase hex characters to match the formatter (`PLE2513`) ([#19808](https://github.com/astral-sh/ruff/pull/19808))
19+
20+
### Documentation
21+
22+
- Fix `lint.future-annotations` link ([#19876](https://github.com/astral-sh/ruff/pull/19876))
23+
24+
### Other changes
25+
26+
- Build `riscv64` binaries for release ([#19819](https://github.com/astral-sh/ruff/pull/19819))
27+
- Add rule code to error description in GitLab output ([#19896](https://github.com/astral-sh/ruff/pull/19896))
28+
329
## 0.12.8
430

531
### Preview features

Cargo.lock

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ curl -LsSf https://astral.sh/ruff/install.sh | sh
148148
powershell -c "irm https://astral.sh/ruff/install.ps1 | iex"
149149

150150
# For a specific version.
151-
curl -LsSf https://astral.sh/ruff/0.12.8/install.sh | sh
152-
powershell -c "irm https://astral.sh/ruff/0.12.8/install.ps1 | iex"
151+
curl -LsSf https://astral.sh/ruff/0.12.9/install.sh | sh
152+
powershell -c "irm https://astral.sh/ruff/0.12.9/install.ps1 | iex"
153153
```
154154

155155
You can also install Ruff via [Homebrew](https://formulae.brew.sh/formula/ruff), [Conda](https://anaconda.org/conda-forge/ruff),
@@ -182,7 +182,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com/) hook via [`ruff
182182
```yaml
183183
- repo: https://github.com/astral-sh/ruff-pre-commit
184184
# Ruff version.
185-
rev: v0.12.8
185+
rev: v0.12.9
186186
hooks:
187187
# Run the linter.
188188
- id: ruff-check

crates/ruff/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ruff"
3-
version = "0.12.8"
3+
version = "0.12.9"
44
publish = true
55
authors = { workspace = true }
66
edition = { workspace = true }

crates/ruff/tests/lint.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5588,15 +5588,15 @@ fn cookiecutter_globbing() -> Result<()> {
55885588
.args(STDIN_BASE_OPTIONS)
55895589
.arg("--select=F811")
55905590
.current_dir(tempdir.path()), @r"
5591-
success: false
5592-
exit_code: 1
5593-
----- stdout -----
5594-
{{cookiecutter.repo_name}}/tests/maintest.py:3:8: F811 [*] Redefinition of unused `foo` from line 1
5595-
Found 1 error.
5596-
[*] 1 fixable with the `--fix` option.
5591+
success: false
5592+
exit_code: 1
5593+
----- stdout -----
5594+
{{cookiecutter.repo_name}}/tests/maintest.py:3:8: F811 [*] Redefinition of unused `foo` from line 1: `foo` redefined here
5595+
Found 1 error.
5596+
[*] 1 fixable with the `--fix` option.
55975597
5598-
----- stderr -----
5599-
");
5598+
----- stderr -----
5599+
");
56005600
});
56015601

56025602
Ok(())

crates/ruff_db/src/diagnostic/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ impl Diagnostic {
254254
.find(|ann| ann.is_primary)
255255
}
256256

257+
/// Returns a mutable borrow of all annotations of this diagnostic.
258+
pub fn annotations_mut(&mut self) -> impl Iterator<Item = &mut Annotation> {
259+
Arc::make_mut(&mut self.inner).annotations.iter_mut()
260+
}
261+
257262
/// Returns the "primary" span of this diagnostic if one exists.
258263
///
259264
/// When there are multiple primary spans, then the first one that was
@@ -310,6 +315,11 @@ impl Diagnostic {
310315
&self.inner.subs
311316
}
312317

318+
/// Returns a mutable borrow of the sub-diagnostics of this diagnostic.
319+
pub fn sub_diagnostics_mut(&mut self) -> impl Iterator<Item = &mut SubDiagnostic> {
320+
Arc::make_mut(&mut self.inner).subs.iter_mut()
321+
}
322+
313323
/// Returns the fix for this diagnostic if it exists.
314324
pub fn fix(&self) -> Option<&Fix> {
315325
self.inner.fix.as_ref()
@@ -621,6 +631,11 @@ impl SubDiagnostic {
621631
&self.inner.annotations
622632
}
623633

634+
/// Returns a mutable borrow of the annotations of this sub-diagnostic.
635+
pub fn annotations_mut(&mut self) -> impl Iterator<Item = &mut Annotation> {
636+
self.inner.annotations.iter_mut()
637+
}
638+
624639
/// Returns a shared borrow of the "primary" annotation of this diagnostic
625640
/// if one exists.
626641
///

crates/ruff_db/src/diagnostic/render.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ impl<'a> ResolvedDiagnostic<'a> {
264264
.annotations
265265
.iter()
266266
.filter_map(|ann| {
267-
let path = ann.span.file.path(resolver);
267+
let path = ann
268+
.span
269+
.file
270+
.relative_path(resolver)
271+
.to_str()
272+
.unwrap_or_else(|| ann.span.file.path(resolver));
268273
let diagnostic_source = ann.span.file.diagnostic_source(resolver);
269274
ResolvedAnnotation::new(path, &diagnostic_source, ann, resolver)
270275
})

crates/ruff_db/src/files.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ impl Files {
8787
.system_by_path
8888
.entry(absolute.clone())
8989
.or_insert_with(|| {
90-
tracing::trace!("Adding file '{path}'");
91-
9290
let metadata = db.system().path_metadata(path);
91+
92+
tracing::trace!("Adding file '{absolute}'");
93+
9394
let durability = self
94-
.root(db, path)
95+
.root(db, &absolute)
9596
.map_or(Durability::default(), |root| root.durability(db));
9697

9798
let builder = File::builder(FilePath::System(absolute))

crates/ruff_linter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ruff_linter"
3-
version = "0.12.8"
3+
version = "0.12.9"
44
publish = false
55
authors = { workspace = true }
66
edition = { workspace = true }

crates/ruff_linter/src/checkers/ast/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use itertools::Itertools;
2828
use log::debug;
2929
use rustc_hash::{FxHashMap, FxHashSet};
3030

31-
use ruff_db::diagnostic::Diagnostic;
31+
use ruff_db::diagnostic::{Annotation, Diagnostic, IntoDiagnosticMessage, Span};
3232
use ruff_diagnostics::{Applicability, Fix, IsolationLevel};
3333
use ruff_notebook::{CellOffsets, NotebookIndex};
3434
use ruff_python_ast::helpers::{collect_import_from_member, is_docstring_stmt, to_module_path};
@@ -3305,6 +3305,17 @@ impl DiagnosticGuard<'_, '_> {
33053305
Err(err) => log::debug!("Failed to create fix for {}: {}", self.name(), err),
33063306
}
33073307
}
3308+
3309+
/// Add a secondary annotation with the given message and range.
3310+
pub(crate) fn secondary_annotation<'a>(
3311+
&mut self,
3312+
message: impl IntoDiagnosticMessage + 'a,
3313+
range: impl Ranged,
3314+
) {
3315+
let span = Span::from(self.context.source_file.clone()).with_range(range.range());
3316+
let ann = Annotation::secondary(span).message(message);
3317+
self.diagnostic.as_mut().unwrap().annotate(ann);
3318+
}
33083319
}
33093320

33103321
impl std::ops::Deref for DiagnosticGuard<'_, '_> {

0 commit comments

Comments
 (0)