Skip to content

Commit 1ab86ba

Browse files
authored
Merge branch 'main' into PYI051
2 parents 8a8abf5 + 38b5726 commit 1ab86ba

File tree

109 files changed

+2526
-1003
lines changed

Some content is hidden

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

109 files changed

+2526
-1003
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ jobs:
5050
- crates/ruff_formatter/**
5151
- crates/ruff_python_trivia/**
5252
- crates/ruff_python_ast/**
53+
- crates/ruff_source_file/**
54+
- crates/ruff_python_index/**
55+
- crates/ruff_text_size/**
56+
- crates/ruff_python_parser/**
5357
5458
5559
cargo-fmt:
@@ -331,7 +335,7 @@ jobs:
331335
- name: "Cache rust"
332336
uses: Swatinem/rust-cache@v2
333337
- name: "Formatter progress"
334-
run: scripts/formatter_progress.sh
338+
run: scripts/formatter_ecosystem_checks.sh
335339
- name: "Github step summary"
336340
run: grep "similarity index" target/progress_projects_report.txt | sort > $GITHUB_STEP_SUMMARY
337341
# CPython is not black formatted, so we run only the stability check

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ syn = { version = "2.0.15" }
4646
test-case = { version = "3.0.0" }
4747
thiserror = { version = "1.0.43" }
4848
toml = { version = "0.7.2" }
49+
tracing = "0.1.37"
50+
tracing-indicatif = "0.3.4"
51+
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
4952
wsl = { version = "0.1.0" }
5053

5154
# v1.0.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Ruff can also be used as a [pre-commit](https://pre-commit.com) hook:
140140
```yaml
141141
- repo: https://github.com/astral-sh/ruff-pre-commit
142142
# Ruff version.
143-
rev: v0.0.280
143+
rev: v0.0.281
144144
hooks:
145145
- id: ruff
146146
```

crates/flake8_to_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 = "flake8-to-ruff"
3-
version = "0.0.280"
3+
version = "0.0.281"
44
description = """
55
Convert Flake8 configuration files to Ruff configuration files.
66
"""

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.0.280"
3+
version = "0.0.281"
44
publish = false
55
authors = { workspace = true }
66
edition = { workspace = true }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import typing
2+
import sys
3+
from typing import TypeAlias
4+
5+
6+
_UnusedPrivateTypeAlias: TypeAlias = int | None
7+
_T: typing.TypeAlias = str
8+
9+
# OK
10+
_UsedPrivateTypeAlias: TypeAlias = int | None
11+
12+
def func(arg: _UsedPrivateTypeAlias) -> _UsedPrivateTypeAlias:
13+
...
14+
15+
16+
if sys.version_info > (3, 9):
17+
_PrivateTypeAlias: TypeAlias = str | None
18+
else:
19+
_PrivateTypeAlias: TypeAlias = float | None
20+
21+
22+
def func2(arg: _PrivateTypeAlias) -> None: ...
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import typing
2+
import sys
3+
from typing import TypeAlias
4+
5+
6+
_UnusedPrivateTypeAlias: TypeAlias = int | None
7+
_T: typing.TypeAlias = str
8+
9+
# OK
10+
_UsedPrivateTypeAlias: TypeAlias = int | None
11+
12+
def func(arg: _UsedPrivateTypeAlias) -> _UsedPrivateTypeAlias:
13+
...
14+
15+
16+
if sys.version_info > (3, 9):
17+
_PrivateTypeAlias: TypeAlias = str | None
18+
else:
19+
_PrivateTypeAlias: TypeAlias = float | None
20+
21+
22+
def func2(arg: _PrivateTypeAlias) -> None: ...
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import typing
2+
from typing import TypedDict
3+
4+
5+
class _UnusedTypedDict(TypedDict):
6+
foo: str
7+
8+
9+
class _UnusedTypedDict2(typing.TypedDict):
10+
bar: int
11+
12+
13+
class _UsedTypedDict(TypedDict):
14+
foo: bytes
15+
16+
17+
class _CustomClass(_UsedTypedDict):
18+
bar: list[int]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sys
2+
import typing
3+
from typing import TypedDict
4+
5+
6+
class _UnusedTypedDict(TypedDict):
7+
foo: str
8+
9+
10+
class _UnusedTypedDict2(typing.TypedDict):
11+
bar: int
12+
13+
14+
# OK
15+
class _UsedTypedDict(TypedDict):
16+
foo: bytes
17+
18+
19+
class _CustomClass(_UsedTypedDict):
20+
bar: list[int]
21+
22+
23+
if sys.version_info >= (3, 10):
24+
class _UsedTypedDict2(TypedDict):
25+
foo: int
26+
else:
27+
class _UsedTypedDict2(TypedDict):
28+
foo: float
29+
30+
31+
class _CustomClass2(_UsedTypedDict2):
32+
bar: list[int]

crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@
3030
(k for k in obj.keys()) # SIM118
3131

3232
key in (obj or {}).keys() # SIM118
33+
34+
from typing import KeysView
35+
36+
37+
class Foo:
38+
def keys(self) -> KeysView[object]:
39+
...
40+
41+
def __contains__(self, key: object) -> bool:
42+
return key in self.keys() # OK
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Regression test: ensure that we don't treat the export entry as a typing-only reference."""
2+
from __future__ import annotations
3+
4+
from logging import getLogger
5+
6+
__all__ = ("getLogger",)
7+
8+
9+
def foo() -> None:
10+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import bar
2+
import foo
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import foo
2+
import bar

0 commit comments

Comments
 (0)