Skip to content

Commit 39244dd

Browse files
committed
Merge remote-tracking branch 'origin/main' into dcreager/typevar-type
* origin/main: [red-knot] Fix more [redundant-cast] false positives (#17170) [red-knot] Three-argument type-calls take 'str' as the first argument (#17168) Control flow: `return` and `raise` (#17121) Bump 0.11.3 (#17173) [red-knot] Improve `Debug` implementation for `semantic_index::SymbolTable` (#17172) [red-knot] Fix `str(…)` calls (#17163) [red-knot] visibility_constraint analysis for match cases (#17077) [red-knot] Fix playground crashes when diagnostics are stale (#17165)
2 parents 8bdd9e2 + ca0cce3 commit 39244dd

File tree

31 files changed

+786
-137
lines changed

31 files changed

+786
-137
lines changed

.github/workflows/mypy_primer.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
--type-checker knot \
6969
--old base_commit \
7070
--new "$GITHUB_SHA" \
71-
--project-selector '/(mypy_primer|black|pyp|git-revise|zipp|arrow|isort|itsdangerous|rich|packaging|pybind11|pyinstrument|typeshed-stats)$' \
71+
--project-selector '/(mypy_primer|black|pyp|git-revise|zipp|arrow|isort|itsdangerous|rich|packaging|pybind11|pyinstrument|typeshed-stats|scrapy)$' \
7272
--output concise \
7373
--debug > mypy_primer.diff || [ $? -eq 1 ]
7474

CHANGELOG.md

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

3+
## 0.11.3
4+
5+
### Preview features
6+
7+
- \[`airflow`\] Add more autofixes for `AIR302` ([#16876](https://github.com/astral-sh/ruff/pull/16876), [#16977](https://github.com/astral-sh/ruff/pull/16977), [#16976](https://github.com/astral-sh/ruff/pull/16976), [#16965](https://github.com/astral-sh/ruff/pull/16965))
8+
- \[`airflow`\] Move `AIR301` to `AIR002` ([#16978](https://github.com/astral-sh/ruff/pull/16978))
9+
- \[`airflow`\] Move `AIR302` to `AIR301` and `AIR303` to `AIR302` ([#17151](https://github.com/astral-sh/ruff/pull/17151))
10+
- \[`flake8-bandit`\] Mark `str` and `list[str]` literals as trusted input (`S603`) ([#17136](https://github.com/astral-sh/ruff/pull/17136))
11+
- \[`ruff`\] Support slices in `RUF005` ([#17078](https://github.com/astral-sh/ruff/pull/17078))
12+
- [syntax-errors] Start detecting compile-time syntax errors ([#16106](https://github.com/astral-sh/ruff/pull/16106))
13+
- [syntax-errors] Duplicate type parameter names ([#16858](https://github.com/astral-sh/ruff/pull/16858))
14+
- [syntax-errors] Irrefutable `case` pattern before final case ([#16905](https://github.com/astral-sh/ruff/pull/16905))
15+
- [syntax-errors] Multiple assignments in `case` pattern ([#16957](https://github.com/astral-sh/ruff/pull/16957))
16+
- [syntax-errors] Single starred assignment target ([#17024](https://github.com/astral-sh/ruff/pull/17024))
17+
- [syntax-errors] Starred expressions in `return`, `yield`, and `for` ([#17134](https://github.com/astral-sh/ruff/pull/17134))
18+
- [syntax-errors] Store to or delete `__debug__` ([#16984](https://github.com/astral-sh/ruff/pull/16984))
19+
20+
### Bug fixes
21+
22+
- Error instead of `panic!` when running Ruff from a deleted directory (#16903) ([#17054](https://github.com/astral-sh/ruff/pull/17054))
23+
- [syntax-errors] Fix false positive for parenthesized tuple index ([#16948](https://github.com/astral-sh/ruff/pull/16948))
24+
25+
### CLI
26+
27+
- Check `pyproject.toml` correctly when it is passed via stdin ([#16971](https://github.com/astral-sh/ruff/pull/16971))
28+
29+
### Configuration
30+
31+
- \[`flake8-import-conventions`\] Add import `numpy.typing as npt` to default `flake8-import-conventions.aliases` ([#17133](https://github.com/astral-sh/ruff/pull/17133))
32+
33+
### Documentation
34+
35+
- \[`refurb`\] Document why `UserDict`, `UserList`, and `UserString` are preferred over `dict`, `list`, and `str` (`FURB189`) ([#16927](https://github.com/astral-sh/ruff/pull/16927))
36+
337
## 0.11.2
438

539
### 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
@@ -149,8 +149,8 @@ curl -LsSf https://astral.sh/ruff/install.sh | sh
149149
powershell -c "irm https://astral.sh/ruff/install.ps1 | iex"
150150

151151
# For a specific version.
152-
curl -LsSf https://astral.sh/ruff/0.11.2/install.sh | sh
153-
powershell -c "irm https://astral.sh/ruff/0.11.2/install.ps1 | iex"
152+
curl -LsSf https://astral.sh/ruff/0.11.3/install.sh | sh
153+
powershell -c "irm https://astral.sh/ruff/0.11.3/install.ps1 | iex"
154154
```
155155

156156
You can also install Ruff via [Homebrew](https://formulae.brew.sh/formula/ruff), [Conda](https://anaconda.org/conda-forge/ruff),
@@ -183,7 +183,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com/) hook via [`ruff
183183
```yaml
184184
- repo: https://github.com/astral-sh/ruff-pre-commit
185185
# Ruff version.
186-
rev: v0.11.2
186+
rev: v0.11.3
187187
hooks:
188188
# Run the linter.
189189
- id: ruff

crates/red_knot_python_semantic/resources/mdtest/call/builtins.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ reveal_type(type(1)) # revealed: Literal[int]
2626
But a three-argument call to type creates a dynamic instance of the `type` class:
2727

2828
```py
29+
class Base: ...
30+
2931
reveal_type(type("Foo", (), {})) # revealed: type
32+
33+
reveal_type(type("Foo", (Base,), {"attr": 1})) # revealed: type
3034
```
3135

3236
Other numbers of arguments are invalid
@@ -38,3 +42,60 @@ type("Foo", ())
3842
# error: [no-matching-overload] "No overload of class `type` matches arguments"
3943
type("Foo", (), {}, weird_other_arg=42)
4044
```
45+
46+
The following calls are also invalid, due to incorrect argument types:
47+
48+
```py
49+
class Base: ...
50+
51+
# error: [no-matching-overload] "No overload of class `type` matches arguments"
52+
type(b"Foo", (), {})
53+
54+
# error: [no-matching-overload] "No overload of class `type` matches arguments"
55+
type("Foo", Base, {})
56+
57+
# TODO: this should be an error
58+
type("Foo", (1, 2), {})
59+
60+
# TODO: this should be an error
61+
type("Foo", (Base,), {b"attr": 1})
62+
```
63+
64+
## Calls to `str()`
65+
66+
### Valid calls
67+
68+
```py
69+
str()
70+
str("")
71+
str(b"")
72+
str(1)
73+
str(object=1)
74+
75+
str(b"M\xc3\xbcsli", "utf-8")
76+
str(b"M\xc3\xbcsli", "utf-8", "replace")
77+
78+
str(b"M\x00\xfc\x00s\x00l\x00i\x00", encoding="utf-16")
79+
str(b"M\x00\xfc\x00s\x00l\x00i\x00", encoding="utf-16", errors="ignore")
80+
81+
str(bytearray.fromhex("4d c3 bc 73 6c 69"), "utf-8")
82+
str(bytearray(), "utf-8")
83+
84+
str(encoding="utf-8", object=b"M\xc3\xbcsli")
85+
str(b"", errors="replace")
86+
str(encoding="utf-8")
87+
str(errors="replace")
88+
```
89+
90+
### Invalid calls
91+
92+
```py
93+
str(1, 2) # error: [no-matching-overload]
94+
str(o=1) # error: [no-matching-overload]
95+
96+
# First argument is not a bytes-like object:
97+
str("Müsli", "utf-8") # error: [no-matching-overload]
98+
99+
# Second argument is not a valid encoding:
100+
str(b"M\xc3\xbcsli", b"utf-8") # error: [no-matching-overload]
101+
```

0 commit comments

Comments
 (0)