Skip to content

Commit 18d7e88

Browse files
committed
Merge branch 'main' into dcreager/tuple-spec
* main: (21 commits) [`flake8-logging`] Avoid false positive for `exc_info=True` outside `logger.exception` (`LOG014`) (#18737) [`flake8-pie`] Small docs fix to `PIE794` (#18829) [`pylint`] Ignore __init__.py files in (PLC0414) (#18400) Avoid generating diagnostics with per-file ignores (#18801) [`flake8-simplify`] Fix false negatives for shadowed bindings (`SIM910`, `SIM911`) (#18794) [ty] Fix panics when pulling types for `ClassVar` or `Final` parameterized with >1 argument (#18824) [`pylint`] add fix safety section (`PLR1714`) (#18415) [Perflint] Small docs improvement to `PERF401` (#18786) [`pylint`] Avoid flattening nested `min`/`max` when outer call has single argument (`PLW3301`) (#16885) [`ruff`] Added `cls.__dict__.get('__annotations__')` check (`RUF063`) (#18233) [ty] Use `HashTable` in `PlaceTable` (#18819) docs: Correct collections-named-tuple example to use PascalCase assignment (#16884) [ty] ecosystem-analyzer workflow (#18719) [ty] Add support for `@staticmethod`s (#18809) unnecessary_dict_kwargs doc - a note on type checking benefits (#18666) [`flake8-pytest-style`] Mark autofix for `PT001` and `PT023` as unsafe if there's comments in the decorator (#18792) [ty] Surface matched overload diagnostic directly (#18452) [ty] Report when a dataclass contains more than one `KW_ONLY` field (#18731) [`flake8-pie`] Add fix safety section to `PIE794` (#18802) [`pycodestyle`] Add fix safety section to `W291` and `W293` (#18800) ...
2 parents 8406319 + 49763a7 commit 18d7e88

File tree

139 files changed

+4279
-1485
lines changed

Some content is hidden

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

139 files changed

+4279
-1485
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: ty ecosystem-analyzer
2+
3+
permissions: {}
4+
5+
on:
6+
pull_request:
7+
types: [labeled]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
11+
cancel-in-progress: true
12+
13+
env:
14+
CARGO_INCREMENTAL: 0
15+
CARGO_NET_RETRY: 10
16+
CARGO_TERM_COLOR: always
17+
RUSTUP_MAX_RETRIES: 10
18+
RUST_BACKTRACE: 1
19+
REF_NAME: ${{ github.ref_name }}
20+
21+
jobs:
22+
ty-ecosystem-analyzer:
23+
name: Compute diagnostic diff
24+
runs-on: depot-ubuntu-22.04-32
25+
timeout-minutes: 20
26+
if: contains(github.event.label.name, 'ecosystem-analyzer')
27+
steps:
28+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
path: ruff
31+
fetch-depth: 0
32+
persist-credentials: false
33+
34+
- name: Install the latest version of uv
35+
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0
36+
37+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
38+
with:
39+
workspaces: "ruff"
40+
41+
- name: Install Rust toolchain
42+
run: rustup show
43+
44+
- name: Compute diagnostic diff
45+
shell: bash
46+
run: |
47+
cd ruff
48+
49+
echo "Enabling configuration overloads (see .github/mypy-primer-ty.toml)"
50+
mkdir -p ~/.config/ty
51+
cp .github/mypy-primer-ty.toml ~/.config/ty/ty.toml
52+
53+
echo "new commit"
54+
git checkout -b new_commit "$GITHUB_SHA"
55+
git rev-list --format=%s --max-count=1 new_commit
56+
cp crates/ty_python_semantic/resources/primer/good.txt projects_new.txt
57+
58+
echo "old commit (merge base)"
59+
MERGE_BASE="$(git merge-base "$GITHUB_SHA" "origin/$GITHUB_BASE_REF")"
60+
git checkout -b old_commit "$MERGE_BASE"
61+
git rev-list --format=%s --max-count=1 old_commit
62+
cp crates/ty_python_semantic/resources/primer/good.txt projects_old.txt
63+
64+
cd ..
65+
66+
uv tool install "git+https://github.com/astral-sh/ecosystem-analyzer@9c34dc514ee9aef6735db1dfebb80f63acbc3440"
67+
68+
ecosystem-analyzer \
69+
--repository ruff \
70+
analyze \
71+
--projects ruff/projects_old.txt \
72+
--commit old_commit \
73+
--output diagnostics_old.json
74+
75+
ecosystem-analyzer \
76+
--repository ruff \
77+
analyze \
78+
--projects ruff/projects_new.txt \
79+
--commit new_commit \
80+
--output diagnostics_new.json
81+
82+
ecosystem-analyzer \
83+
generate-diff \
84+
diagnostics_old.json \
85+
diagnostics_new.json \
86+
--old-name "main (merge base)" \
87+
--new-name "$REF_NAME" \
88+
--output-html diff.html
89+
90+
- name: Upload HTML diff report
91+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
92+
with:
93+
name: diff.html
94+
path: diff.html

crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C401.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,19 @@ def f(x):
3636
# some more
3737
)
3838

39+
# t-strings
40+
print(t"Hello {set(f(a) for a in 'abc')} World")
41+
print(t"Hello { set(f(a) for a in 'abc') } World")
42+
small_nums = t"{set(a if a < 6 else 0 for a in range(3))}"
43+
print(t"Hello {set(a for a in range(3))} World")
44+
print(t"{set(a for a in 'abc') - set(a for a in 'ab')}")
45+
print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }")
46+
47+
3948
# Not built-in set.
4049
def set(*args, **kwargs):
4150
return None
4251

4352
set(2 * x for x in range(3))
4453
set(x for x in range(3))
54+

crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C403.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,16 @@ def f(x):
3434
))))
3535

3636
# Test trailing comma case
37-
s = set([x for x in range(3)],)
37+
s = set([x for x in range(3)],)
38+
39+
s = t"{set([x for x in 'ab'])}"
40+
s = t'{set([x for x in "ab"])}'
41+
42+
def f(x):
43+
return x
44+
45+
s = t"{set([f(x) for x in 'ab'])}"
46+
47+
s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }"
48+
s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}"
49+

crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C405.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@
2424
f"{ set(['a', 'b']) - set(['a']) }"
2525
f"a {set(['a', 'b']) - set(['a'])} b"
2626
f"a { set(['a', 'b']) - set(['a']) } b"
27+
28+
t"{set([1,2,3])}"
29+
t"{set(['a', 'b'])}"
30+
t'{set(["a", "b"])}'
31+
32+
t"{set(['a', 'b']) - set(['a'])}"
33+
t"{ set(['a', 'b']) - set(['a']) }"
34+
t"a {set(['a', 'b']) - set(['a'])} b"
35+
t"a { set(['a', 'b']) - set(['a']) } b"

crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C408.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@ def list():
2727

2828
tuple( # comment
2929
)
30+
31+
t"{dict(x='y')}"
32+
t'{dict(x="y")}'
33+
t"{dict()}"
34+
t"a {dict()} b"
35+
36+
t"{dict(x='y') | dict(y='z')}"
37+
t"{ dict(x='y') | dict(y='z') }"
38+
t"a {dict(x='y') | dict(y='z')} b"
39+
t"a { dict(x='y') | dict(y='z') } b"

crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C417.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,8 @@ def func(arg1: int, arg2: int = 4):
7070
list(map(lambda x, y: x, [(1, 2), (3, 4)]))
7171
list(map(lambda: 1, "xyz"))
7272
list(map(lambda x, y: x, [(1, 2), (3, 4)]))
73+
74+
# When inside t-string, then the fix should be surrounded by whitespace
75+
_ = t"{set(map(lambda x: x % 2 == 0, nums))}"
76+
_ = t"{dict(map(lambda v: (v, v**2), nums))}"
77+

crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG014_0.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ def _():
3232

3333
### No errors
3434

35+
logging.info("", exc_info=ValueError())
36+
logger.info("", exc_info=ValueError())
37+
38+
logging.info("", exc_info=(exc_type, exc_value, exc_traceback))
39+
logger.info("", exc_info=(exc_type, exc_value, exc_traceback))
40+
3541
logging.info("", exc_info=a)
3642
logger.info("", exc_info=a)
3743

crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT001.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,10 @@ def aliased_parentheses_with_params():
7676
)
7777
def aliased_parentheses_no_params_multiline():
7878
return 42
79+
80+
# https://github.com/astral-sh/ruff/issues/18770
81+
@pytest.fixture(
82+
# TODO: use module scope
83+
# scope="module"
84+
)
85+
def my_fixture(): ...

crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT023.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,14 @@ class TestNestedClass:
7777
@pytest.mark.foo()
7878
def test_something():
7979
pass
80+
81+
# https://github.com/astral-sh/ruff/issues/18770
82+
@pytest.mark.parametrize(
83+
# TODO: fix later
84+
# ("param1", "param2"),
85+
# (
86+
# (1, 2),
87+
# (3, 4),
88+
# ),
89+
)
90+
def test_bar(param1, param2): ...

crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM910.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ def foo(some_other: object):
4949
# OK
5050
def foo(some_other):
5151
a = some_other.get('a', None)
52+
53+
54+
# https://github.com/astral-sh/ruff/issues/18777
55+
def foo():
56+
dict = {"Tom": 23, "Maria": 23, "Dog": 11}
57+
age = dict.get("Cat", None)

0 commit comments

Comments
 (0)