Commit Graph

13671 Commits

Author SHA1 Message Date
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
justin
938c1c5e12 [ty] diagnostic on overridden __setattr__ and __delattr__ in frozen dataclasses (#21430)
## Summary
https://github.com/astral-sh/ty/issues/111

this pr adds an `invalid-dataclass-override` diagnostic when a custom
`__setattr__` or `__delattr__` is defined on a dataclass where
`frozen=True`
([docs](https://docs.python.org/3/library/dataclasses.html#frozen-instances))

### Runtime exception
```
Traceback (most recent call last):
  File "/Users/justinchapman/src/ty-playground/main.py", line 4, in <module>
    @dataclass(frozen=True)
     ~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/justinchapman/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/dataclasses.py", line 1295, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
                          frozen, match_args, kw_only, slots,
                          weakref_slot)
  File "/Users/justinchapman/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/dataclasses.py", line 1157, in _process_class
    func_builder.add_fns_to_class(cls)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/Users/justinchapman/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/dataclasses.py", line 516, in add_fns_to_class
    raise TypeError(error_msg)
TypeError: Cannot overwrite attribute __setattr__ in class A
```

### Diagnostic
```
error[invalid-dataclass-override]: Cannot overwrite attribute __setattr__ in class A
 --> /Users/justinchapman/src/ty-playground/main.py:6:5
  |
4 | @dataclass(frozen=True)
5 | class A:
6 |     def __setattr__(self, name: str, value: object) -> None: ...
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
info: __setattr__
info: rule `invalid-dataclass-override` is enabled by default

Found 1 diagnostic
```

## Test Plan
- new mdtests
- e2e
- the `attrs` mypy primer diff looks to be a [true
positive](https://github.com/python-attrs/attrs/blob/main/tests/test_setattr.py#L373)
- the other results have been unpredictable and have changed every time
i pushed new code, even if the diagnostic logic didn't change...

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2026-01-17 02:24:39 +00:00
Leandro Braga
20d80edfc2 [flake8-bugbear] Mark fix unsafe when it would remove comments (B033) (#22632)
The B033 erroneously removes comments in safe fix.

By running
```console
$ cargo run -p ruff  -- check --select B033 - << 'EOF'
{
  1,
  # comment
  1
}
EOF
```

We get:

# Before

```console
B033 [*] Sets should not contain duplicate item `1`
 --> -:4:3
  |
2 |   1,
3 |   # comment
4 |   1
  |   ^
5 | }
  |
help: Remove duplicate item

Found 1 error.
[*] 1 fixable with the `--fix` option.
```

# After
```console
B033 Sets should not contain duplicate item `1`
 --> -:4:3
  |
2 |   1,
3 |   # comment
4 |   1
  |   ^
5 | }
  |
help: Remove duplicate item

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
```

Closes #22629
2026-01-16 19:07:19 -05:00
Alex Waygood
717d024ea9 [ty] Generalize union-type subtyping fast path (#22495) 2026-01-16 22:09:06 +00:00
Leandro Braga
b80d8ff6ff [ruff] Detect duplicate entries in __all__ (RUF068) (#22114)
Hello,

This MR adds a new rule and its fix, `RUF069`,
`DuplicateEntryInDunderAll`. I'm using `RUF069` because we already have
[RUF068](https://github.com/astral-sh/ruff/pull/20585) and
[RUF069](https://github.com/astral-sh/ruff/pull/21079#issuecomment-3493839453)
in the works.

The rule job is to prevent users from accidentally adding duplicate
entries to `__all__`, which, for example, can result from copy-paste
mistakes.

It deals with the following syntaxes:

```python
__all__: list[str] = ["a", "a"]
__all__: typing.Any = ("a", "a")
__all__.extend(["a", "a"])
__all__ += ["a", "a"]
```

But it does not keep track of `__all__` contents, meaning the following
code snippet is a false negative:
```python
class A: ...

__all__ = ["A"]
__all__.extend(["A"])
```

## Violation Example

```console
RUF069 `__all__` contains duplicate entries
 --> RUF069.py:2:17
  |
1 | __all__ = ["A", "A", "B"]
  |                 ^^^
help: Remove duplicate entries from `__all__`
1 | __all__ = ["A", "B"]
  - __all__ = ["A", "A", "B"]
```

## Ecosystem Report

The `ruff-ecosystem` results contain seven violations in four projects,
all of them seem like true positives, with one instance appearing to be
an actual bug.

This [code
snippet](90d855985b/stubs/reportlab/reportlab/lib/rltempfile.pyi (L4))
from `reportlab` contains the same entry twice instead of exporting both
functions.

```python
def get_rl_tempdir(*subdirs: str) -> str: ...
def get_rl_tempfile(fn: str | None = None) -> str: ...

__all__ = ("get_rl_tempdir", "get_rl_tempdir")
```

Closes [#21945](https://github.com/astral-sh/ruff/issues/21945)

---------

Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2026-01-16 14:58:06 -05:00
Amethyst Reese
337e3ebd27 Combine suppression code diagnostics (#22613)
# Summary

- Report a single combined UnusedNOQA diagnostic when any range
suppression
  has one or more unused, disabled, or duplicate lint codes.
- Report a single combined InvalidRuleCode diagnostic for any range
suppression
  with one or more invalid lint codes.

# Test Plan

Updated fixtures and snapshots

Fixes #22429, #21873
2026-01-16 11:08:48 -08:00
Dex Devlon
5c97b6ef40 [ty] Correct return type for synthesized NamedTuple.__new__ methods (#22625) 2026-01-16 18:56:56 +00:00
Alex Waygood
ed355b6173 [ty] Rename some narrowing-related machinery (#22618) 2026-01-16 17:10:33 +00:00
Alex Waygood
a2b383842a [ty] Allow ... as a default value for any parameter if the function is in an if TYPE_CHECKING block (#22624) 2026-01-16 16:32:38 +00:00
Micha Reiser
a636fbe91c Remove ty_python_semantic dependency from ruff_graph (#22623)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-16 16:17:05 +01:00
konsti
10fd3b2415 Use explicit manylinux/musllinux targets and better pre-upload checks (#22477)
This ensures that changes to the targets are intentional and explicit.

See also https://github.com/astral-sh/ty/pull/2393 and
https://github.com/astral-sh/uv/pull/17358
2026-01-16 14:26:52 +00:00
Micha Reiser
eb99f80a02 [ty] Extract ty_site_packages crate (#22622) 2026-01-16 15:02:47 +01:00
Alex Waygood
3c323559ed More fixes to scripts/conformance.py (#22616) 2026-01-16 12:47:39 +00:00
Alex Waygood
0cc3a775cd Tell Claude to prefer using #[expect()] over #[allow()] where possible (#22617) 2026-01-16 12:36:32 +00:00
Alex Waygood
28bfcf82b8 [ty] Make ModuleType and object attributes available on namespace packages (#22606)
## Summary

Currently we don't think that namespace packages (e.g. `google` after
you've pip-installed `google-cloud-ndb`) have attributes such as
`__file__`, `__name__`, etc. This PR fixes that.

## Test Plan

Mdtests and snapshots.
2026-01-16 08:42:58 +00:00
Micha Reiser
4adbf7798d [ty] Fix --force-exclude when excluding entire directories (#22595) 2026-01-16 09:23:26 +01:00
Caíque Porfirio
0ce5ce4de1 [ruff] Add exception for ctypes.Structure._fields_ (RUF012) (#22559)
Closes #22166 
## Summary
Adds an exception for `ctypes.Structure._fields_` to the rule RUF012 as
it has it's own way of enforcing immutability:

> The fields class variable can only be set once. Later assignments will
raise an
[AttributeError](https://docs.python.org/3/library/exceptions.html#AttributeError).

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
2026-01-15 20:49:59 +00:00