Skip to content

Commit 9ddb01c

Browse files
author
UnboundVariable
committed
Merge branch 'main' into symbols
* main: [ty] Added support for "document highlights" language server feature. (astral-sh#19515) Add support for specifying minimum dots in detected string imports (astral-sh#19538) [ty] Minor: fix incomplete docstring (astral-sh#19534) [ty] Move server tests as integration tests (astral-sh#19522) [`ruff`] Offer fixes for `RUF039` in more cases (astral-sh#19065) [ty] Support `dataclasses.InitVar` (astral-sh#19527) [`ruff`] Fix `RUF033` breaking with named default expressions (astral-sh#19115) Update pre-commit hook name (astral-sh#19530) Bump 0.12.5 (astral-sh#19528) [ty] Rename type_api => ty_extensions (astral-sh#19523) [ty] Added support for "go to references" in ty playground. (astral-sh#19516) # Conflicts: # crates/ty_server/src/server/api/requests.rs # crates/ty_server/tests/e2e/snapshots/e2e__initialize__initialization.snap # crates/ty_server/tests/e2e/snapshots/e2e__initialize__initialization_with_workspace.snap
2 parents 9645990 + 4bc34b8 commit 9ddb01c

File tree

68 files changed

+3188
-1161
lines changed

Some content is hidden

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

68 files changed

+3188
-1161
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ repos:
8484
rev: v0.12.4
8585
hooks:
8686
- id: ruff-format
87-
- id: ruff
87+
- id: ruff-check
8888
args: [--fix, --exit-non-zero-on-fix]
8989
types_or: [python, pyi]
9090
require_serial: true

CHANGELOG.md

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

3+
## 0.12.5
4+
5+
### Preview features
6+
7+
- \[`flake8-use-pathlib`\] Add autofix for `PTH101`, `PTH104`, `PTH105`, `PTH121` ([#19404](https://github.com/astral-sh/ruff/pull/19404))
8+
- \[`ruff`\] Support byte strings (`RUF055`) ([#18926](https://github.com/astral-sh/ruff/pull/18926))
9+
10+
### Bug fixes
11+
12+
- Fix `unreachable` panic in parser ([#19183](https://github.com/astral-sh/ruff/pull/19183))
13+
- \[`flake8-pyi`\] Skip fix if all `Union` members are `None` (`PYI016`) ([#19416](https://github.com/astral-sh/ruff/pull/19416))
14+
- \[`perflint`\] Parenthesize generator expressions (`PERF401`) ([#19325](https://github.com/astral-sh/ruff/pull/19325))
15+
- \[`pylint`\] Handle empty comments after line continuation (`PLR2044`) ([#19405](https://github.com/astral-sh/ruff/pull/19405))
16+
17+
### Rule changes
18+
19+
- \[`pep8-naming`\] Fix `N802` false positives for `CGIHTTPRequestHandler` and `SimpleHTTPRequestHandler` ([#19432](https://github.com/astral-sh/ruff/pull/19432))
20+
321
## 0.12.4
422

523
### Preview features

Cargo.lock

Lines changed: 5 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.4/install.sh | sh
152-
powershell -c "irm https://astral.sh/ruff/0.12.4/install.ps1 | iex"
151+
curl -LsSf https://astral.sh/ruff/0.12.5/install.sh | sh
152+
powershell -c "irm https://astral.sh/ruff/0.12.5/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.4
185+
rev: v0.12.5
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.4"
3+
version = "0.12.5"
44
publish = true
55
authors = { workspace = true }
66
edition = { workspace = true }

crates/ruff/src/args.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ pub struct AnalyzeGraphCommand {
169169
/// Attempt to detect imports from string literals.
170170
#[clap(long)]
171171
detect_string_imports: bool,
172+
/// The minimum number of dots in a string import to consider it a valid import.
173+
#[clap(long)]
174+
min_dots: Option<usize>,
172175
/// Enable preview mode. Use `--no-preview` to disable.
173176
#[arg(long, overrides_with("no_preview"))]
174177
preview: bool,
@@ -808,6 +811,7 @@ impl AnalyzeGraphCommand {
808811
} else {
809812
None
810813
},
814+
string_imports_min_dots: self.min_dots,
811815
preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from),
812816
target_version: self.target_version.map(ast::PythonVersion::from),
813817
..ExplicitConfigOverrides::default()
@@ -1305,6 +1309,7 @@ struct ExplicitConfigOverrides {
13051309
show_fixes: Option<bool>,
13061310
extension: Option<Vec<ExtensionPair>>,
13071311
detect_string_imports: Option<bool>,
1312+
string_imports_min_dots: Option<usize>,
13081313
}
13091314

13101315
impl ConfigurationTransformer for ExplicitConfigOverrides {
@@ -1392,6 +1397,9 @@ impl ConfigurationTransformer for ExplicitConfigOverrides {
13921397
if let Some(detect_string_imports) = &self.detect_string_imports {
13931398
config.analyze.detect_string_imports = Some(*detect_string_imports);
13941399
}
1400+
if let Some(string_imports_min_dots) = &self.string_imports_min_dots {
1401+
config.analyze.string_imports_min_dots = Some(*string_imports_min_dots);
1402+
}
13951403

13961404
config
13971405
}

crates/ruff/src/commands/analyze_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub(crate) fn analyze_graph(
102102

103103
// Resolve the per-file settings.
104104
let settings = resolver.resolve(path);
105-
let string_imports = settings.analyze.detect_string_imports;
105+
let string_imports = settings.analyze.string_imports;
106106
let include_dependencies = settings.analyze.include_dependencies.get(path).cloned();
107107

108108
// Skip excluded files.

crates/ruff/tests/analyze_graph.rs

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,43 @@ fn string_detection() -> Result<()> {
197197
insta::with_settings!({
198198
filters => INSTA_FILTERS.to_vec(),
199199
}, {
200-
assert_cmd_snapshot!(command().arg("--detect-string-imports").current_dir(&root), @r###"
201-
success: true
202-
exit_code: 0
203-
----- stdout -----
204-
{
205-
"ruff/__init__.py": [],
206-
"ruff/a.py": [
207-
"ruff/b.py"
208-
],
209-
"ruff/b.py": [
210-
"ruff/c.py"
211-
],
212-
"ruff/c.py": []
213-
}
200+
assert_cmd_snapshot!(command().arg("--detect-string-imports").current_dir(&root), @r#"
201+
success: true
202+
exit_code: 0
203+
----- stdout -----
204+
{
205+
"ruff/__init__.py": [],
206+
"ruff/a.py": [
207+
"ruff/b.py"
208+
],
209+
"ruff/b.py": [],
210+
"ruff/c.py": []
211+
}
214212
215-
----- stderr -----
216-
"###);
213+
----- stderr -----
214+
"#);
215+
});
216+
217+
insta::with_settings!({
218+
filters => INSTA_FILTERS.to_vec(),
219+
}, {
220+
assert_cmd_snapshot!(command().arg("--detect-string-imports").arg("--min-dots").arg("1").current_dir(&root), @r#"
221+
success: true
222+
exit_code: 0
223+
----- stdout -----
224+
{
225+
"ruff/__init__.py": [],
226+
"ruff/a.py": [
227+
"ruff/b.py"
228+
],
229+
"ruff/b.py": [
230+
"ruff/c.py"
231+
],
232+
"ruff/c.py": []
233+
}
234+
235+
----- stderr -----
236+
"#);
217237
});
218238

219239
Ok(())

crates/ruff/tests/lint.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,7 +2422,7 @@ requires-python = ">= 3.11"
24222422
analyze.exclude = []
24232423
analyze.preview = disabled
24242424
analyze.target_version = 3.11
2425-
analyze.detect_string_imports = false
2425+
analyze.string_imports = disabled
24262426
analyze.extension = ExtensionMapping({})
24272427
analyze.include_dependencies = {}
24282428
@@ -2734,7 +2734,7 @@ requires-python = ">= 3.11"
27342734
analyze.exclude = []
27352735
analyze.preview = disabled
27362736
analyze.target_version = 3.10
2737-
analyze.detect_string_imports = false
2737+
analyze.string_imports = disabled
27382738
analyze.extension = ExtensionMapping({})
27392739
analyze.include_dependencies = {}
27402740
@@ -3098,7 +3098,7 @@ from typing import Union;foo: Union[int, str] = 1
30983098
analyze.exclude = []
30993099
analyze.preview = disabled
31003100
analyze.target_version = 3.11
3101-
analyze.detect_string_imports = false
3101+
analyze.string_imports = disabled
31023102
analyze.extension = ExtensionMapping({})
31033103
analyze.include_dependencies = {}
31043104
@@ -3478,7 +3478,7 @@ from typing import Union;foo: Union[int, str] = 1
34783478
analyze.exclude = []
34793479
analyze.preview = disabled
34803480
analyze.target_version = 3.11
3481-
analyze.detect_string_imports = false
3481+
analyze.string_imports = disabled
34823482
analyze.extension = ExtensionMapping({})
34833483
analyze.include_dependencies = {}
34843484
@@ -3806,7 +3806,7 @@ from typing import Union;foo: Union[int, str] = 1
38063806
analyze.exclude = []
38073807
analyze.preview = disabled
38083808
analyze.target_version = 3.10
3809-
analyze.detect_string_imports = false
3809+
analyze.string_imports = disabled
38103810
analyze.extension = ExtensionMapping({})
38113811
analyze.include_dependencies = {}
38123812
@@ -4134,7 +4134,7 @@ from typing import Union;foo: Union[int, str] = 1
41344134
analyze.exclude = []
41354135
analyze.preview = disabled
41364136
analyze.target_version = 3.9
4137-
analyze.detect_string_imports = false
4137+
analyze.string_imports = disabled
41384138
analyze.extension = ExtensionMapping({})
41394139
analyze.include_dependencies = {}
41404140
@@ -4419,7 +4419,7 @@ from typing import Union;foo: Union[int, str] = 1
44194419
analyze.exclude = []
44204420
analyze.preview = disabled
44214421
analyze.target_version = 3.9
4422-
analyze.detect_string_imports = false
4422+
analyze.string_imports = disabled
44234423
analyze.extension = ExtensionMapping({})
44244424
analyze.include_dependencies = {}
44254425
@@ -4757,7 +4757,7 @@ from typing import Union;foo: Union[int, str] = 1
47574757
analyze.exclude = []
47584758
analyze.preview = disabled
47594759
analyze.target_version = 3.10
4760-
analyze.detect_string_imports = false
4760+
analyze.string_imports = disabled
47614761
analyze.extension = ExtensionMapping({})
47624762
analyze.include_dependencies = {}
47634763

crates/ruff/tests/snapshots/show_settings__display_default_settings.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ formatter.docstring_code_line_width = dynamic
392392
analyze.exclude = []
393393
analyze.preview = disabled
394394
analyze.target_version = 3.7
395-
analyze.detect_string_imports = false
395+
analyze.string_imports = disabled
396396
analyze.extension = ExtensionMapping({})
397397
analyze.include_dependencies = {}
398398

0 commit comments

Comments
 (0)