Ruff 0.11.0 (#16723)

## Summary

Follow-up release for Ruff v0.10 that now includes the following two
changes that we intended to ship but slipped:

* Changes to how the Python version is inferred when a `target-version`
is not specified (#16319)
* `blanket-noqa` (`PGH004`): Also detect blanked file-level noqa
comments (and not just line level comments).

## Test plan

I verified that the binary built on this branch respects the
`requires-python` setting
([logs](https://www.diffchecker.com/qyJWYi6W/), left: v0.10, right:
v0.11)
This commit is contained in:
Micha Reiser 2025-03-14 13:57:56 +01:00 committed by GitHub
parent a22d206db2
commit 2cd25ef641
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 51 additions and 22 deletions

View file

@ -1,6 +1,8 @@
# Breaking Changes
## 0.10.0
## 0.11.0
This is a follow-up to release 0.10.0. Because of a mistake in the release process, the `requires-python` inference changes were not included in that release. Ruff 0.11.0 now includes this change as well as the stabilization of the preview behavior for `PGH004`.
- **Changes to how the Python version is inferred when a `target-version` is not specified** ([#16319](https://github.com/astral-sh/ruff/pull/16319))
@ -23,6 +25,13 @@
search for the closest `pyproject.toml` in the parent directories and use its
`requires-python` setting.
## 0.10.0
- **Changes to how the Python version is inferred when a `target-version` is not specified** ([#16319](https://github.com/astral-sh/ruff/pull/16319))
Because of a mistake in the release process, the `requires-python` inference changes are not included in this release and instead shipped as part of 0.11.0.
You can find a description of this change in the 0.11.0 section.
- **Updated `TYPE_CHECKING` behavior** ([#16669](https://github.com/astral-sh/ruff/pull/16669))
Previously, Ruff only recognized typechecking blocks that tested the `typing.TYPE_CHECKING` symbol. Now, Ruff recognizes any local variable named `TYPE_CHECKING`. This release also removes support for the legacy `if 0:` and `if False:` typechecking checks. Use a local `TYPE_CHECKING` variable instead.

View file

@ -1,13 +1,11 @@
# Changelog
## 0.10.0
## 0.11.0
Check out the [blog post](https://astral.sh/blog/ruff-v0.10.0) for a migration guide and overview of the changes!
This is a follow-up to release 0.10.0. Because of a mistake in the release process, the `requires-python` inference changes were not included in that release. Ruff 0.11.0 now includes this change as well as the stabilization of the preview behavior for `PGH004`.
### Breaking changes
See also, the "Remapped rules" section which may result in disabled rules.
- **Changes to how the Python version is inferred when a `target-version` is not specified** ([#16319](https://github.com/astral-sh/ruff/pull/16319))
In previous versions of Ruff, you could specify your Python version with:
@ -29,6 +27,29 @@ See also, the "Remapped rules" section which may result in disabled rules.
search for the closest `pyproject.toml` in the parent directories and use its
`requires-python` setting.
### Stabilization
The following behaviors have been stabilized:
- [`blanket-noqa`](https://docs.astral.sh/ruff/rules/blanket-noqa/) (`PGH004`): Also detect blanked file-level noqa comments (and not just line level comments).
### Preview features
- [syntax-errors] Tuple unpacking in `for` statement iterator clause before Python 3.9 ([#16558](https://github.com/astral-sh/ruff/pull/16558))
## 0.10.0
Check out the [blog post](https://astral.sh/blog/ruff-v0.10.0) for a migration guide and overview of the changes!
### Breaking changes
See also, the "Remapped rules" section which may result in disabled rules.
- **Changes to how the Python version is inferred when a `target-version` is not specified** ([#16319](https://github.com/astral-sh/ruff/pull/16319))
Because of a mistake in the release process, the `requires-python` inference changes are not included in this release and instead shipped as part of 0.11.0.
You can find a description of this change in the 0.11.0 section.
- **Updated `TYPE_CHECKING` behavior** ([#16669](https://github.com/astral-sh/ruff/pull/16669))
Previously, Ruff only recognized typechecking blocks that tested the `typing.TYPE_CHECKING` symbol. Now, Ruff recognizes any local variable named `TYPE_CHECKING`. This release also removes support for the legacy `if 0:` and `if False:` typechecking checks. Use a local `TYPE_CHECKING` variable instead.
@ -86,7 +107,6 @@ The following behaviors have been stabilized:
- [`bad-staticmethod-argument`](https://docs.astral.sh/ruff/rules/bad-staticmethod-argument/) (`PLW0211`) [`invalid-first-argument-name-for-class-method`](https://docs.astral.sh/ruff/rules/invalid-first-argument-name-for-class-method/) (`N804`): `__new__` methods are now no longer flagged by `invalid-first-argument-name-for-class-method` (`N804`) but instead by `bad-staticmethod-argument` (`PLW0211`)
- [`bad-str-strip-call`](https://docs.astral.sh/ruff/rules/bad-str-strip-call/) (`PLE1310`): The rule now applies to objects which are known to have type `str` or `bytes`.
- [`blanket-noqa`](https://docs.astral.sh/ruff/rules/blanket-noqa/) (`PGH004`): Also detect blanked file-level noqa comments (and not just line level comments).
- [`custom-type-var-for-self`](https://docs.astral.sh/ruff/rules/custom-type-var-for-self/) (`PYI019`): More accurate detection of custom `TypeVars` replaceable by `Self`. The range of the diagnostic is now the full function header rather than just the return annotation.
- [`invalid-argument-name`](https://docs.astral.sh/ruff/rules/invalid-argument-name/) (`N803`): Ignore argument names of functions decorated with `typing.override`
- [`invalid-envvar-default`](https://docs.astral.sh/ruff/rules/invalid-envvar-default/) (`PLW1508`): Detect default value arguments to `os.environ.get` with invalid type.

6
Cargo.lock generated
View file

@ -2659,7 +2659,7 @@ dependencies = [
[[package]]
name = "ruff"
version = "0.10.0"
version = "0.11.0"
dependencies = [
"anyhow",
"argfile",
@ -2894,7 +2894,7 @@ dependencies = [
[[package]]
name = "ruff_linter"
version = "0.10.0"
version = "0.11.0"
dependencies = [
"aho-corasick",
"anyhow",
@ -3217,7 +3217,7 @@ dependencies = [
[[package]]
name = "ruff_wasm"
version = "0.10.0"
version = "0.11.0"
dependencies = [
"console_error_panic_hook",
"console_log",

View file

@ -149,8 +149,8 @@ curl -LsSf https://astral.sh/ruff/install.sh | sh
powershell -c "irm https://astral.sh/ruff/install.ps1 | iex"
# For a specific version.
curl -LsSf https://astral.sh/ruff/0.10.0/install.sh | sh
powershell -c "irm https://astral.sh/ruff/0.10.0/install.ps1 | iex"
curl -LsSf https://astral.sh/ruff/0.11.0/install.sh | sh
powershell -c "irm https://astral.sh/ruff/0.11.0/install.ps1 | iex"
```
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
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.10.0
rev: v0.11.0
hooks:
# Run the linter.
- id: ruff

View file

@ -1,6 +1,6 @@
[package]
name = "ruff"
version = "0.10.0"
version = "0.11.0"
publish = true
authors = { workspace = true }
edition = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "ruff_linter"
version = "0.10.0"
version = "0.11.0"
publish = false
authors = { workspace = true }
edition = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "ruff_wasm"
version = "0.10.0"
version = "0.11.0"
publish = false
authors = { workspace = true }
edition = { workspace = true }

View file

@ -80,7 +80,7 @@ You can add the following configuration to `.gitlab-ci.yml` to run a `ruff forma
stage: build
interruptible: true
image:
name: ghcr.io/astral-sh/ruff:0.10.0-alpine
name: ghcr.io/astral-sh/ruff:0.11.0-alpine
before_script:
- cd $CI_PROJECT_DIR
- ruff --version
@ -106,7 +106,7 @@ Ruff can be used as a [pre-commit](https://pre-commit.com) hook via [`ruff-pre-c
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.10.0
rev: v0.11.0
hooks:
# Run the linter.
- id: ruff
@ -119,7 +119,7 @@ To enable lint fixes, add the `--fix` argument to the lint hook:
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.10.0
rev: v0.11.0
hooks:
# Run the linter.
- id: ruff
@ -133,7 +133,7 @@ To avoid running on Jupyter Notebooks, remove `jupyter` from the list of allowed
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.10.0
rev: v0.11.0
hooks:
# Run the linter.
- id: ruff

View file

@ -365,7 +365,7 @@ This tutorial has focused on Ruff's command-line interface, but Ruff can also be
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.10.0
rev: v0.11.0
hooks:
# Run the linter.
- id: ruff

View file

@ -4,7 +4,7 @@ build-backend = "maturin"
[project]
name = "ruff"
version = "0.10.0"
version = "0.11.0"
description = "An extremely fast Python linter and code formatter, written in Rust."
authors = [{ name = "Astral Software Inc.", email = "hey@astral.sh" }]
readme = "README.md"

View file

@ -1,6 +1,6 @@
[project]
name = "scripts"
version = "0.10.0"
version = "0.11.0"
description = ""
authors = ["Charles Marsh <charlie.r.marsh@gmail.com>"]