Commit Graph

13687 Commits

Author SHA1 Message Date
Alex Waygood
de0189618f Bump the typing conformance workflow to use the latest python/typing commit (#22727) 2026-01-19 16:20:37 +00:00
Hugo
8fab35019b [ty] Fix panic on malformed mdtest assertion (#22724) 2026-01-19 15:56:42 +00:00
chiri
c5902a3cdb [refurb] Make fix unsafe if it deletes comments (FURB140) (#22679)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
2026-01-19 10:33:18 -05:00
chiri
bffc95873d [refurb] Make fix unsafe if it deletes comments (FURB136) (#22680)
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
2026-01-19 10:17:24 -05:00
Micha Reiser
2bc4756716 PIE794: Detect duplicated declared class fields (#22717) 2026-01-19 15:35:58 +01:00
Charlie Marsh
7f9b10a193 [ty] Narrow on bool and byte subscripts (#22684)
## Summary

Low-hanging fruit...
2026-01-19 14:31:38 +00:00
Alex Waygood
5949fa0b93 [ty] Improve readability of some NamedTuple code (#22723) 2026-01-19 14:10:22 +00:00
Charlie Marsh
2abaff046e [ty] Narrow on negative subscript indexing (#22682)
## Summary

Negative subscripts are also indicative of a thing being subcriptable:

```python
class Subscriptable:
    def __getitem__(self, key: int) -> int:
        return 42

class NotSubscriptable: ...

def _(x: list[Subscriptable | NotSubscriptable]):
    if not isinstance(x[-1], NotSubscriptable):
        # After narrowing, x[-1] excludes NotSubscriptable, which means subscripting works
        reveal_type(x[-1])  # revealed: Subscriptable & ~NotSubscriptable
        reveal_type(x[-1][0])  # revealed: int
```
2026-01-19 09:04:08 -05:00
Charlie Marsh
0793bfdb16 [ty] Avoid overload errors when detecting dataclass-on-tuple (#22687)
## Summary

Fixes some TODOs introduced in #22672 around cases like the following:


```python
from collections import namedtuple
from dataclasses import dataclass

NT = namedtuple("NT", "x y")

# error: [invalid-dataclass] "Cannot use `dataclass()` on a `NamedTuple` class"
dataclass(NT)
```

On main, `dataclass(NT)` emits `# error: [no-matching-overload]`
instead, which is wrong -- the overload does match! On main, the logic
proceeds as follows:

1. `dataclass` has two overloads:
  - `dataclass(cls: type[_T], ...) -> type[_T]`
  - `dataclass(cls: None = None, ...) -> Callable[[type[_T]], type[_T]]`
2. When `dataclass(NT)` is called:
- Arity check: Both overloads accept one positional argument, so both
pass.
- Type checking on first overload: `NT` matches `type[_T]`... but then
`invalid_dataclass_target()` runs and adds `InvalidDataclassApplication`
error
- Type checking on second overload: `NT` doesn't match `None`, so we
have a type error.
3. After type checking, both overloads have errors.
4. `matching_overload_index()` filters by
`overload.as_result().is_ok()`, which checks if `errors.is_empty()`.
Since both overloads have errors, neither matches...
5. We emit the "No overload matches arguments" error.

Instead, we now differentiate between non-matching errors, and errors
that occur when we _do_ match, but the call has some other semantic
failure.
2026-01-19 13:55:11 +00:00
Alex Waygood
aac0562c28 [ty] Fix the inferred MRO of functional namedtuple classes (#22722) 2026-01-19 13:48:51 +00:00
Charlie Marsh
52ce26bd41 [ty] Avoid reporting overload errors for successful union variants (#22688)
## Summary

Consider `x: str | bytes` and then `x.split(" ")`. Because we have a
union, and at least one variant errors (`bytes` expects a `Buffer`, not
a `str`), we call `binding.report_diagnostics` for each variant. For the
`str` variant, it has two overloads that both match arity, but only one
actually matches the signature... So
`matching_overload_before_type_checking` is `None` (because they both
match arity), but we don't actually have an error, and we fall through
to `NO_MATCHING_OVERLOAD`.

If one variant succeeds, we should avoid reporting errors for it, even
if not _all_ variants matched.
2026-01-19 08:40:31 -05:00
K900
ebc59e81f6 Skip EXE0xx tests on WSL (#22721) 2026-01-19 13:31:54 +00:00
Alex Waygood
9eff10c79f [ty] Use smallvec_inline! more consistently (#22720) 2026-01-19 13:29:01 +00:00
Alex Waygood
d19c962d5e [ty] Use fluent style more, and reduce allocations, when constructing Parameters instances (#22719) 2026-01-19 13:23:28 +00:00
Micha Reiser
55a174ed95 [ty] Update 'added-in' version of some rules (#22713) 2026-01-19 09:39:35 +01:00
Zanie Blue
bc05cc3c6f [ty] Cache ClassType::nearest_disjoint_base (#22065) 2026-01-19 09:22:53 +01:00
Micha Reiser
65b7fc9e73 [ty] Support overriding respect-type-ignore-comments (#22615) 2026-01-19 08:09:42 +00:00
renovate[bot]
c50863a0ee Update dependency pyright to v1.1.408 (#22696)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2026-01-19 07:59:38 +00:00
renovate[bot]
d6e0b013ba Update prek dependencies (#22698)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2026-01-19 07:50:15 +00:00
renovate[bot]
a226611724 Update taiki-e/install-action action to v2.66.1 (#22712) 2026-01-18 20:57:07 -05:00
renovate[bot]
9db3d704d8 Update dependency mdformat-mkdocs to v5.1.2 (#22695) 2026-01-18 20:56:56 -05:00
renovate[bot]
09c526e312 Update NPM Development dependencies (#22709) 2026-01-18 20:55:40 -05:00
renovate[bot]
7a8c9b1617 Update Rust crate jiff to v0.2.18 (#22699) 2026-01-18 20:53:51 -05:00
renovate[bot]
b6998a4a25 Update Rust crate toml to v0.9.11 (#22706) 2026-01-18 20:53:37 -05:00
renovate[bot]
06822977c9 Update Rust crate snapbox to v0.6.24 (#22704) 2026-01-18 20:53:14 -05:00
renovate[bot]
a7299be431 Update Rust crate url to v2.5.8 (#22707) 2026-01-18 20:53:04 -05:00
renovate[bot]
77da8a68be Update dependency tomli to v2.4.0 (#22708) 2026-01-18 20:53:00 -05:00
renovate[bot]
7addbb5e2d Update Rust crate indexmap to v2.13.0 (#22710) 2026-01-18 20:52:57 -05:00
renovate[bot]
6bf6139772 Update Rust crate syn to v2.0.114 (#22705) 2026-01-18 20:52:38 -05:00
renovate[bot]
fcb9832d2d Update Rust crate quote to v1.0.43 (#22702) 2026-01-18 20:52:35 -05:00
renovate[bot]
e3da1757d9 Update Rust crate proc-macro2 to v1.0.105 (#22701) 2026-01-18 20:52:31 -05:00
renovate[bot]
709d74d831 Update Rust crate ordermap to v1.1.0 (#22711) 2026-01-18 20:52:20 -05:00
renovate[bot]
bdc4ea4af3 Update Rust crate libc to v0.2.180 (#22700) 2026-01-19 01:08:35 +00:00
renovate[bot]
8fc99864a8 Update Rust crate serde_json to v1.0.149 (#22703) 2026-01-19 01:03:54 +00:00
renovate[bot]
371d60cff1 Update dependency ruff to v0.14.13 (#22697)
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [ruff](https://docs.astral.sh/ruff)
([source](https://redirect.github.com/astral-sh/ruff),
[changelog](https://redirect.github.com/astral-sh/ruff/blob/main/CHANGELOG.md))
| `==0.14.11` → `==0.14.13` |
![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.14.13?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.14.11/0.14.13?slim=true)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.14.13`](https://redirect.github.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#01413)

Released on 2026-01-15.

This is a follow-up release to 0.14.12. Because of an issue publishing
the WASM packages, there is no GitHub release or Git tag for 0.14.12,
although the package was published to PyPI. The contents of the 0.14.13
release are identical to 0.14.12.

###
[`v0.14.12`](https://redirect.github.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#01412)

Released on 2026-01-15.

##### Preview features

- \[`flake8-blind-except`] Allow more logging methods (`BLE001`)
([#&#8203;22057](https://redirect.github.com/astral-sh/ruff/pull/22057))
- \[`ruff`] Respect `lint.pydocstyle.property-decorators` in `RUF066`
([#&#8203;22515](https://redirect.github.com/astral-sh/ruff/pull/22515))

##### Bug fixes

- Fix configuration path in `--show-settings`
([#&#8203;22478](https://redirect.github.com/astral-sh/ruff/pull/22478))
- Respect `fmt: skip` for multiple statements on the same logical line
([#&#8203;22119](https://redirect.github.com/astral-sh/ruff/pull/22119))

##### Rule changes

- \[`pydocstyle`] Update Rust crate imperative to v1.0.7 (`D401`)
([#&#8203;22519](https://redirect.github.com/astral-sh/ruff/pull/22519))
- \[`isort`] Insert imports in alphabetical order (`I002`)
([#&#8203;22493](https://redirect.github.com/astral-sh/ruff/pull/22493))

##### Documentation

- Add llms.txt support for documentation
([#&#8203;22463](https://redirect.github.com/astral-sh/ruff/pull/22463))
- Use prek in documentation and CI
([#&#8203;22505](https://redirect.github.com/astral-sh/ruff/pull/22505))
- \[`flake8-pytest-style`] Add `check` parameter example to `PT017` docs
([#&#8203;22546](https://redirect.github.com/astral-sh/ruff/pull/22546))
- \[`ruff`] Make example error out-of-the-box (`RUF103`)
([#&#8203;22558](https://redirect.github.com/astral-sh/ruff/pull/22558))
- \[`ruff`] document `RUF100` trailing comment fix behavior
([#&#8203;22479](https://redirect.github.com/astral-sh/ruff/pull/22479))

##### Other changes

- wasm: Require explicit logging initialization
([#&#8203;22587](https://redirect.github.com/astral-sh/ruff/pull/22587))

##### Contributors

- [@&#8203;terror](https://redirect.github.com/terror)
- [@&#8203;harupy](https://redirect.github.com/harupy)
- [@&#8203;Jkhall81](https://redirect.github.com/Jkhall81)
- [@&#8203;dhruvmanila](https://redirect.github.com/dhruvmanila)
- [@&#8203;lubaskinc0de](https://redirect.github.com/lubaskinc0de)
- [@&#8203;zanieb](https://redirect.github.com/zanieb)
- [@&#8203;MeGaGiGaGon](https://redirect.github.com/MeGaGiGaGon)
- [@&#8203;charliermarsh](https://redirect.github.com/charliermarsh)
- [@&#8203;renovate](https://redirect.github.com/renovate)
- [@&#8203;dylwil3](https://redirect.github.com/dylwil3)
- [@&#8203;MichaReiser](https://redirect.github.com/MichaReiser)
- [@&#8203;11happy](https://redirect.github.com/11happy)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43NC41IiwidXBkYXRlZEluVmVyIjoiNDIuNzQuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-19 01:01:25 +00:00
Alex Waygood
7c9803310e [ty] Set None as the definition of Self type variables (#22648) 2026-01-18 19:04:40 +00:00
Alexandr
bab571c12c [ty] Recognize string-literal types as subtypes of Sequence[Literal[chars]] (#22415)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2026-01-18 17:43:44 +00:00
Charlie Marsh
57c98a1f07 [ty] Emit diagnostic for NamedTuple and TypedDict decorated with dataclass (#22672)
## Summary

Closes https://github.com/astral-sh/ty/issues/2515.

Closes https://github.com/astral-sh/ty/issues/2527.
2026-01-18 17:20:09 +00:00
Micha Reiser
0e5bac06c8 [ty] Highlight interpolated-parts in t-strings (#22674)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-18 12:37:12 +00:00
Micha Reiser
bbe295a846 [ty] Fix missing syntax highlighting for aliased import names (#22675)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-18 12:14:42 +00:00
Alex Waygood
7b534a9b89 scripts/conformance.py: fix collection of diagnostics (#22671) 2026-01-18 11:52:38 +00:00
Charlie Marsh
ac8c85eb8c [ty] Support passing typename and field_names by keyword argument (#22660)
## Summary

Closes https://github.com/astral-sh/ty/issues/2549.
2026-01-17 19:02:34 -05:00
Kevin Yang
704d30f473 [airflow] Second positional argument to Asset/Dataset should not be a dictionary (AIR303) (#22453)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

This PR is related to https://github.com/apache/airflow/issues/48389.

In Airflow 3, the function signature for `airflow.Dataset`,
`airflow.datasets.Dataset`, and `airflow.sdk.Asset` has changed. Below
is the function signature for `airflow.sdk.Asset`. The second positional
argument is `uri` which is of type `str`. In the older version, the
second positional argument can be a dictionary which is the `extra:
'dict | None' = None` argument. Therefore, we need to flag this in
Airflow 3.

```python
Asset(name: 'str | None' = None, uri: 'str | None' = None, *, group: 'str | None' = None, extra: 'dict | None' = None, watchers: 'list[AssetWatcher | SerializedAssetWatcher] | None' = None) -> 'None'
```

As this is a check on constructor call, we need to create a new method
`check_constructor_arguments`, instead of on method call. The new rule
check whether the index 1 (the second argument) is a dictionary (either
a literal or a `dict()` call).

## Test Plan

The `AIR303.py` test file have been updated with new test cases. The
snapshot has been updated and all other test cases passed.

@Lee-W , could you please review it when you have a chance, and let me
know if you have further feedback. Thanks!
2026-01-17 15:16:12 -05:00
Alex Waygood
3608c620ac [ty] Right-hand side narrowing for if Foo is type(x) expressions (#22608) 2026-01-17 15:49:51 +00:00
Charlie Marsh
df58d67974 [ty] Validate constructor arguments when a class is used as a decorator (#22377)
## Summary

If a class is used as a decorator, we now use the class constructor.

Closes https://github.com/astral-sh/ty/issues/2232.
2026-01-17 10:48:59 -05:00
Alex Waygood
6b16931169 [ty] Simple syntactic validation for PEP-613 type aliases (#22652) 2026-01-17 15:43:50 +00:00
Alex Waygood
2e4774623c [ty] Ban NewTypes with generic bases (#22653) 2026-01-17 15:23:53 +00:00
Alex Waygood
ca57b2595e conformance.py: Only use the "No changes detected " summary if no diagnostics were added or removed (#22649) 2026-01-17 13:30:45 +00:00
Will Duke
dfd236c028 [ty] Handle optional errors in conformance workflow (#22647) 2026-01-17 12:47:45 +00:00
Matthew Mckee
ebf7d0cd2f [ty] Don't add a subdiagnostic pointing to the TypeVar definition if the TypeVar is Self (#22646) 2026-01-17 12:41:37 +00:00