Skip to content

Commit 1f937bd

Browse files
author
UnboundVariable
committed
Merge branch 'main' of https://github.com/astral-sh/ruff into doc_highlight
* 'main' of https://github.com/astral-sh/ruff: [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) [ty] Return a tuple spec from the iterator protocol (astral-sh#19496) [ty] Exhaustiveness checking & reachability for `match` statements (astral-sh#19508) [ty] Fix narrowing and reachability of class patterns with arguments (astral-sh#19512)
2 parents ba8b09a + d77b731 commit 1f937bd

61 files changed

Lines changed: 2033 additions & 432 deletions

File tree

Some content is hidden

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

.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: 4 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_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.4"
3+
version = "0.12.5"
44
publish = false
55
authors = { workspace = true }
66
edition = { workspace = true }

crates/ruff_linter/resources/test/fixtures/ruff/RUF033.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,62 @@ class Foo:
6565
bar = "should've used attrs"
6666

6767
def __post_init__(self, bar: str = "ahhh", baz: str = "hmm") -> None: ...
68+
69+
70+
# https://github.com/astral-sh/ruff/issues/18950
71+
@dataclass
72+
class Foo:
73+
def __post_init__(self, bar: int = (x := 1)) -> None:
74+
pass
75+
76+
77+
@dataclass
78+
class Foo:
79+
def __post_init__(
80+
self,
81+
bar: int = (x := 1) # comment
82+
,
83+
baz: int = (y := 2), # comment
84+
foo = (a := 1) # comment
85+
,
86+
faz = (b := 2), # comment
87+
) -> None:
88+
pass
89+
90+
91+
@dataclass
92+
class Foo:
93+
def __post_init__(
94+
self,
95+
bar: int = 1, # comment
96+
baz: int = 2, # comment
97+
) -> None:
98+
pass
99+
100+
101+
@dataclass
102+
class Foo:
103+
def __post_init__(
104+
self,
105+
arg1: int = (1) # comment
106+
,
107+
arg2: int = ((1)) # comment
108+
,
109+
arg2: int = (i for i in range(10)) # comment
110+
,
111+
) -> None:
112+
pass
113+
114+
115+
# makes little sense, but is valid syntax
116+
def fun_with_python_syntax():
117+
@dataclass
118+
class Foo:
119+
def __post_init__(
120+
self,
121+
bar: (int) = (yield from range(5)) # comment
122+
,
123+
) -> None:
124+
...
125+
126+
return Foo

crates/ruff_linter/resources/test/fixtures/ruff/RUF039.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@
5353
regex.splititer(both, non_literal)
5454
regex.subf(f, lambda _: r'means', '"format"')
5555
regex.subfn(fn, f'''a$1n't''', lambda: "'function'")
56+
57+
58+
# https://github.com/astral-sh/ruff/issues/16713
59+
re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41") # with unsafe fix
60+
re.compile("\b") # without fix
61+
re.compile("\"") # without fix
62+
re.compile("\'") # without fix
63+
re.compile('\"') # without fix
64+
re.compile('\'') # without fix
65+
re.compile("\\") # without fix
66+
re.compile("\101") # without fix
67+
re.compile("a\
68+
b") # without fix

crates/ruff_linter/resources/test/fixtures/ruff/RUF039_concat.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,20 @@
9191
br''br""br''
9292
)
9393
regex.subfn(br'I\s\nee*d\s[O0o]me\x20\Qoffe\E, ' br'b')
94+
95+
96+
# https://github.com/astral-sh/ruff/issues/16713
97+
re.compile(
98+
"["
99+
"\U0001F600-\U0001F64F" # emoticons
100+
"\U0001F300-\U0001F5FF" # symbols & pictographs
101+
"\U0001F680-\U0001F6FF" # transport & map symbols
102+
"\U0001F1E0-\U0001F1FF" # flags (iOS)
103+
"\U00002702-\U000027B0"
104+
"\U000024C2-\U0001F251"
105+
"\u200d" # zero width joiner
106+
"\u200c" # zero width non-joiner
107+
"\\u200c" # must not be escaped in a raw string
108+
"]+",
109+
flags=re.UNICODE,
110+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import re
2+
3+
re.compile("\N{Partial Differential}") # with unsafe fix if python target is 3.8 or higher, else without fix

0 commit comments

Comments
 (0)