Compare commits

..

33 Commits

Author SHA1 Message Date
Zanie Blue
6c2d87ed80 Invert case 2025-12-20 22:31:37 -06:00
Zanie Blue
7d4831597b Lint 2025-12-20 22:31:37 -06:00
Zanie Blue
81f39680d2 [ty] Cache Type::is_disjoint_from 2025-12-20 22:31:37 -06:00
Zanie Blue
3c2f534480 [ty] Cache Type::is_subtype_of 2025-12-20 22:31:37 -06:00
Zanie Blue
592a674447 [ty] Cache ClassType::nearest_disjoint_base 2025-12-20 22:31:37 -06:00
Ibraheem Ahmed
ad41728204 [ty] Avoid temporarily storing invalid multi-inference attempts (#22103)
## Summary

I missed this in https://github.com/astral-sh/ruff/pull/22062. This
avoids exponential runtime in the following snippet:

```py
class X1: ...
class X2: ...
class X3: ...
class X4: ...
class X5: ...
class X6: ...
...

def f(
    x:
        list[X1 | None]
      | list[X2 | None]
      | list[X3 | None]
      | list[X4 | None]
      | list[X5 | None]
      | list[X6 | None]
      ...
):
    ...

def g[T](x: T) -> list[T]:
    return [x]

def id[T](x: T) -> T:
    return x

f(id(id(id(id(g(X64()))))))
```

Eventually I want to refactor our multi-inference infrastructure (which
is currently very brittle) to handle this implicitly, but this is a
temporary performance fix until that happens.
2025-12-20 08:20:53 -08:00
Hugo
3ec63b964c [ty] Add support for dict(...) calls in typed dict contexts (#22113)
## Summary

fixes https://github.com/astral-sh/ty/issues/2127
- handle `dict(...)` calls in TypedDict context with bidirectional
inference
- validate keys/values using the existing TypedDict constructor implem
- mdtest: add 1 positive test, 1 negative test for invalid coverage

## Test Plan

```sh
cargo clippy --workspace --all-targets --all-features -- -D warnings  # Rust linting
cargo test  # Rust testing
uvx pre-commit run --all-files --show-diff-on-failure  # Rust and Python formatting, Markdown and Python linting, etc.
```
fully green
2025-12-20 07:59:03 -08:00
Matthew Mckee
f9a0e1e3f6 [ty] Fix panic introduced in #22076 (#22112)
<!--
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

Was looking over that PR and this looked wrong.

panic introduced in #22076 

## Test Plan

Before running:

```bash
cargo run -p ty check test.py --force-exclude --no-progress 
```

would result in a panic

```text
thread 'main' (162713) panicked at crates/ty/src/args.rs:459:17:
internal error: entered unreachable code: Clap should make this impossible
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Now it does not.
2025-12-20 07:53:45 -08:00
William Woodruff
ef4507be96 Remove in-workflow deployment to Cloudflare Pages (#22098) 2025-12-20 10:21:47 -05:00
Alex Waygood
3398ab23a9 Update comments in sync_typeshed.yaml workflow (#22109) 2025-12-20 12:19:04 +00:00
Micha Reiser
5b475b45aa [ty] Add --force-exclude option (#22076) 2025-12-20 10:03:41 +01:00
Ibraheem Ahmed
2a959ef3f2 [ty] Avoid narrowing on non-generic calls (#22102)
## Summary

Resolves https://github.com/astral-sh/ty/issues/2026.
2025-12-19 23:18:07 -05:00
Ibraheem Ahmed
674d3902c6 [ty] Only prefer declared types in non-covariant positions (#22068)
## Summary

The following snippet currently errors because we widen the inferred
type, even though `X` is covariant over `T`. If `T` was contravariant or
invariant, this would be fine, as it would lead to an assignability
error anyways.

```python
class X[T]:
    def __init__(self: X[None]): ...

    def pop(self) -> T:
        raise NotImplementedError

# error: Argument to bound method `__init__` is incorrect: Expected `X[None]`, found `X[int | None]`
x: X[int | None] = X()
```

There are some cases where it is still helpful to prefer covariant
declared types, but this error seems hard to fix otherwise, and makes
our heuristics more consistent overall.
2025-12-19 17:27:31 -05:00
Alex Waygood
1a18ada931 [ty] Run mypy_primer and typing-conformance workflows on fewer PRs (#22096)
## Summary

Fixes https://github.com/astral-sh/ty/issues/2090. Quoting my rationale
from that issue:

> A PR that only touches code in [one of these crates] should never have
any impact on memory usage or diagnostics produced. And the comments
from the bot just lead to additional notifications which is annoying.

I _think_ I've got the syntax right here. The
[docs](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax)
say:

>  The order that you define paths patterns matters:
>
> - A matching negative pattern (prefixed with !) after a positive match
will exclude the path.
> - A matching positive pattern after a negative match will include the
path again.

## Test Plan

No idea? Merge it and see?
2025-12-19 19:31:20 +00:00
Alex Waygood
dde0d0af68 [ty] List rules in alphabetical order in the reference docs (#22097)
## Summary

Fixes https://github.com/astral-sh/ty/issues/1885.

It wasn't obvious to me that there was a deliberate order to the way
these rules were listed in our reference docs -- it looked like it was
_nearly_ alphabetical, but not quite. I think it's simpler if we just
list them in alphabetical order.

## Test Plan

The output from running `cargo dev generate-all` (committed as part of
this PR) looks correct!
2025-12-19 19:11:05 +00:00
Chris Bachhuber
b342f60b40 Update T201 suggestion to not use root logger to satisfy LOG015 (#22059)
## Summary

Currently, the proposed fix for https://docs.astral.sh/ruff/rules/print/
violates https://docs.astral.sh/ruff/rules/root-logger-call/. Thus,
let's change the proposal to make LOG015 happy as well.

## Test Plan

Test manually in a project that has both T201 and LOG015 enabled and run
them over the previous and proposed code. Is there continuous testing of
the code snippets from the docs?
2025-12-19 11:08:12 -08:00
Alex Waygood
2151c3d351 [ty] Document that several rules are disabled by default because of the number of false positives they produce (#22095) 2025-12-19 18:45:18 +00:00
Aria Desires
cdb7a9fb33 [ty] Classify docstrings in semantic tokens (syntax highlighting) (#22031)
## Summary

* Related to, but does not handle
https://github.com/astral-sh/ty/issues/2021

## Test Plan

I also added some snapshot tests for future work on non-standard
attribute docstrings (didn't want to highlight them if we don't
recognize them elsewhere).
2025-12-19 13:36:01 -05:00
github-actions[bot]
df1552b9a4 [ty] Sync vendored typeshed stubs (#22091)
Co-authored-by: typeshedbot <>
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2025-12-19 18:23:09 +00:00
Alex Waygood
77de3df150 [ty] Fix sync-typeshed workflow timeouts (#22090) 2025-12-19 18:09:08 +00:00
Charlie Marsh
0f18a08a0a [ty] Respect intersections in iterations (#21965)
## Summary

This PR implements the strategy described in
https://github.com/astral-sh/ty/issues/1871: we iterate over the
positive types, resolve them, then intersect the results.
2025-12-19 12:36:37 -05:00
William Woodruff
b63b3c13fb Upload full ecosystem report as a GitHub Actions artifact (#22086) 2025-12-19 11:41:21 -05:00
Ibraheem Ahmed
270d755621 [ty] Avoid storing invalid multi-inference attempts (#22062)
## Summary

This should make revealed types a little nicer, as well as avoid
confusing the constraint solver in some cases (which were showing up in
https://github.com/astral-sh/ruff/pull/21930).
2025-12-19 15:38:47 +00:00
Micha Reiser
9809405b05 [ty] Only clear output between two successful checks (#22078) 2025-12-19 15:16:54 +01:00
Alex Waygood
28cdbb18c5 [ty] Minor followups to #22048 (#22082) 2025-12-19 13:58:59 +00:00
Alex Waygood
f9d1a282fb [ty] Collect mdtest failures as part of the assertion message rather than printing them to the terminal immediately (#22081) 2025-12-19 13:53:31 +00:00
David Peter
0bac023cd2 [ty] Lockfiles for mdtests with external dependencies (#22077)
## Summary

Add lockfiles for all mdtests which make use of external dependencies.
When running tests normally, we use this lockfile when creating the
temporary venv using `uv sync --locked`. A new
`MDTEST_UPGRADE_LOCKFILES` environment variable is used to switch to a
mode in which those lockfiles can be updated or regenerated. When using
the Python mdtest runner, this environment variable is automatically set
(because we use this command while developing, not to simulate exactly
what happens in CI). A command-line flag is provided to opt out of this.

## Test Plan

### Using the mdtest runner

#### Adding a new test (no lockfile yet)

* Removed `attrs.lock` to simulate this
* Ran `uv run crates/ty_python_semantic/mdtest.py -e external/`. The
lockfile is generated and the test succeeds.

#### Upgrading/downgrading a dependency

* Changed pydantic requirement from `pydantic==2.12.2` to
`pydantic==2.12.5` (also tested with `2.12.0`)
* Ran `uv run crates/ty_python_semantic/mdtest.py -e external/`. The
lockfile is updated and the test succeeds.

### Using cargo

#### Adding a new test (no lockfile yet)

* Removed `attrs.lock` to simulate this
* Ran `MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest
mdtest__external` "naively", which outputs:
> Failed to setup in-memory virtual environment with dependencies:
Lockfile not found at
'/home/shark/ruff/crates/ty_python_semantic/resources/mdtest/external/attrs.lock'.
Run with `MDTEST_UPGRADE_LOCKFILES=1` to generate it.
* Ran `MDTEST_UPGRADE_LOCKFILES=1 MDTEST_EXTERNAL=1 cargo test -p
ty_python_semantic --test mdtest mdtest__external`. The lockfile is
updated and the test succeeds.

#### Upgrading/downgrading a dependency

* Changed pydantic requirement from `pydantic==2.12.2` to
`pydantic==2.12.5` (also tested with `2.12.0`)
* Ran `MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest
mdtest__external` "naively", which outputs a similar error message as
above.
* Ran the command suggested in the error message (`MDTEST_EXTERNAL=1
MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test
mdtest mdtest__external`). The lockfile is updated and the test
succeeds.
2025-12-19 14:29:52 +01:00
Micha Reiser
30efab8138 [ty] Only print dashed line for failing tests (#22080) 2025-12-19 14:20:03 +01:00
RasmusNygren
58d25129aa [ty] Visit class arguments in source order for semantic tokens (#22063)
Co-authored-by: Micha Reiser <micha@reiser.io>
2025-12-19 13:19:49 +00:00
Micha Reiser
e177cc2a5a [ty] Improve union builder performance (#22048) 2025-12-19 08:29:16 +01:00
Micha Reiser
30ce679b9a [ty] Fix rules severity URL (#22069) 2025-12-19 07:25:02 +00:00
Charlie Marsh
76854fdb15 [ty] Unwrap enum.nonmember values (#22025)
## Summary

This PR unwraps the `enum.nonmember` type to match runtime behavior.

Closes https://github.com/astral-sh/ty/issues/1974.
2025-12-18 19:59:49 -05:00
Douglas Creager
5a2d3cda3d [ty] Remove some nondeterminism in constraint set tests (#22064)
We're seeing a lot of nondeterminism in the ecosystem tests at the
moment, which started (or at least got worse) once `Callable` inference
landed.

This PR attempts to remove this nondeterminism. We recently
(https://github.com/astral-sh/ruff/pull/21983) added a `source_order`
field to BDD nodes, which tracks when their constraint was added to the
BDD. Since we build up constraints based on the order that they appear
in the underlying source, that gives us a stable ordering even though we
use an arbitrary salsa-derived ordering for the BDD variables.

The issue (at least for some of the flakiness) is that we add "derived"
constraints when walking a BDD tree, and those derived constraints
inherit or borrow the `source_order` of the "real" constraint that
implied them. That means we can get multiple constraints in our
specialization that all have the same `source_order`. If we're not
careful, those "tied" constraints can be ordered arbitrarily.

The fix requires ~three~ ~four~ several steps:

- When starting to construct a sequent map (the data structure that
stores the derived constraints), we first sort all of the "real"
constraints by their `source_order`. That ensures that we insert things
into the sequent map in a stable order.
- During sequent map construction, derived facts are discovered by a
deterministic process applied to constraints in a (now) stable order. So
derived facts are now also inserted in a stable order.
- We update the fields of `SequentMap` to use `FxOrderSet` instead of
`FxHashSet`, so that we retain that stable insertion order.
- When walking BDD paths when constructing a specialization, we were
already sorting the constraints by their `source_order`. However, we
were not considering that we might get derived constraints, and
therefore constraints with "ties". Because of that, we need to make sure
to use a _stable_ sort, that retains the insertion order for those ties.

All together, this...should...fix the nondeterminism. (Unfortunately, I
haven't been able to effectively test this, since I haven't been able to
coerce local tests to flop into the other order that we sometimes see in
CI.)
2025-12-18 19:00:20 -05:00
328 changed files with 4474 additions and 1845 deletions

1
.gitattributes vendored
View File

@@ -22,6 +22,7 @@ crates/ruff_linter/resources/test/fixtures/pyupgrade/UP018_CR.py text eol=cr
crates/ruff_linter/resources/test/fixtures/pyupgrade/UP018_LF.py text eol=lf
crates/ruff_python_parser/resources/inline linguist-generated=true
crates/ty_python_semantic/resources/mdtest/external/*.lock linguist-generated=true
ruff.schema.json -diff linguist-generated=true text=auto eol=lf
ty.schema.json -diff linguist-generated=true text=auto eol=lf

View File

@@ -62,7 +62,7 @@ jobs:
name: Create an issue if the daily fuzz surfaced any bugs
runs-on: ubuntu-latest
needs: fuzz
if: ${{ github.repository == 'astral-sh/ruff' && always() && github.event_name == 'schedule' && needs.fuzz.result == 'failure' }}
if: ${{ github.repository == 'astral-sh/ruff' && always() && github.event_name == 'schedule' && needs.fuzz.result != 'success' }}
permissions:
issues: write
steps:

View File

@@ -6,6 +6,11 @@ on:
pull_request:
paths:
- "crates/ty*/**"
- "!crates/ty_ide/**"
- "!crates/ty_server/**"
- "!crates/ty_test/**"
- "!crates/ty_completion_eval/**"
- "!crates/ty_wasm/**"
- "crates/ruff_db"
- "crates/ruff_python_ast"
- "crates/ruff_python_parser"

View File

@@ -16,8 +16,7 @@ name: Sync typeshed
# 3. Once the Windows worker is done, a MacOS worker:
# a. Checks out the branch created by the Linux worker
# b. Syncs all docstrings available on MacOS that are not available on Linux or Windows
# c. Attempts to update any snapshots that might have changed
# (this sub-step is allowed to fail)
# c. Formats the code again
# d. Commits the changes and pushes them to the same upstream branch
# e. Creates a PR against the `main` branch using the branch all three workers have pushed to
# 4. If any of steps 1-3 failed, an issue is created in the `astral-sh/ruff` repository
@@ -198,42 +197,6 @@ jobs:
run: |
rm "${VENDORED_TYPESHED}/pyproject.toml"
git commit -am "Remove pyproject.toml file"
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
- name: "Install Rust toolchain"
if: ${{ success() }}
run: rustup show
- name: "Install mold"
if: ${{ success() }}
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
- name: "Install cargo nextest"
if: ${{ success() }}
uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60
with:
tool: cargo-nextest
- name: "Install cargo insta"
if: ${{ success() }}
uses: taiki-e/install-action@3575e532701a5fc614b0c842e4119af4cc5fd16d # v2.62.60
with:
tool: cargo-insta
- name: Update snapshots
if: ${{ success() }}
run: |
cargo r \
--profile=profiling \
-p ty_completion_eval \
-- all --tasks ./crates/ty_completion_eval/completion-evaluation-tasks.csv
# The `cargo insta` docs indicate that `--unreferenced=delete` might be a good option,
# but from local testing it appears to just revert all changes made by `cargo insta test --accept`.
#
# If there were only snapshot-related failures, `cargo insta test --accept` will have exit code 0,
# but if there were also other mdtest failures (for example), it will return a nonzero exit code.
# We don't care about other tests failing here, we just want snapshots updated where possible,
# so we use `|| true` here to ignore the exit code.
cargo insta test --accept --color=always --all-features --test-runner=nextest || true
- name: Commit snapshot changes
if: ${{ success() }}
run: git commit -am "Update snapshots" || echo "No snapshot changes to commit"
- name: Push changes upstream and create a PR
if: ${{ success() }}
run: |
@@ -245,7 +208,7 @@ jobs:
name: Create an issue if the typeshed sync failed
runs-on: ubuntu-latest
needs: [sync, docstrings-windows, docstrings-macos-and-pr]
if: ${{ github.repository == 'astral-sh/ruff' && always() && github.event_name == 'schedule' && (needs.sync.result == 'failure' || needs.docstrings-windows.result == 'failure' || needs.docstrings-macos-and-pr.result == 'failure') }}
if: ${{ github.repository == 'astral-sh/ruff' && always() && github.event_name == 'schedule' && (needs.sync.result != 'success' || needs.docstrings-windows.result != 'success' || needs.docstrings-macos-and-pr.result != 'success') }}
permissions:
issues: write
steps:

View File

@@ -17,7 +17,6 @@ env:
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1
REF_NAME: ${{ github.ref_name }}
CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }}
jobs:
ty-ecosystem-analyzer:
@@ -112,22 +111,13 @@ jobs:
cat diff-statistics.md >> "$GITHUB_STEP_SUMMARY"
- name: "Deploy to Cloudflare Pages"
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
id: deploy
uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1
# NOTE: astral-sh-bot uses this artifact to post comments on PRs.
# Make sure to update the bot if you rename the artifact.
- name: "Upload full report"
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages deploy dist --project-name=ty-ecosystem --branch ${{ github.head_ref }} --commit-hash ${GITHUB_SHA}
- name: "Append deployment URL"
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
env:
DEPLOYMENT_URL: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
run: |
echo >> comment.md
echo "**[Full report with detailed diff]($DEPLOYMENT_URL/diff)** ([timing results]($DEPLOYMENT_URL/timing))" >> comment.md
name: full-report
path: dist/
# NOTE: astral-sh-bot uses this artifact to post comments on PRs.
# Make sure to update the bot if you rename the artifact.

View File

@@ -6,6 +6,11 @@ on:
pull_request:
paths:
- "crates/ty*/**"
- "!crates/ty_ide/**"
- "!crates/ty_server/**"
- "!crates/ty_test/**"
- "!crates/ty_completion_eval/**"
- "!crates/ty_wasm/**"
- "crates/ruff_db"
- "crates/ruff_python_ast"
- "crates/ruff_python_parser"

View File

@@ -2,7 +2,6 @@ use std::fmt::Write as _;
use std::io::{self, BufWriter, Write};
use anyhow::Result;
use ruff_diagnostics::Applicability;
use serde::ser::SerializeSeq;
use serde::{Serialize, Serializer};
use strum::IntoEnumIterator;
@@ -22,7 +21,6 @@ struct Explanation<'a> {
message_formats: &'a [&'a str],
fix: String,
fix_availability: FixAvailability,
fix_safety: Applicability,
#[expect(clippy::struct_field_names)]
explanation: Option<&'a str>,
preview: bool,
@@ -43,7 +41,6 @@ impl<'a> Explanation<'a> {
message_formats: rule.message_formats(),
fix,
fix_availability: rule.fixable(),
fix_safety: rule.applicability(),
explanation: rule.explanation(),
preview: rule.is_preview(),
status: rule.group(),

View File

@@ -23,7 +23,6 @@ exit_code: 0
],
"fix": "Fix is sometimes available.",
"fix_availability": "Sometimes",
"fix_safety": "unsafe",
"explanation": "## What it does\nChecks for unused imports.\n\n## Why is this bad?\nUnused imports add a performance overhead at runtime, and risk creating\nimport cycles. They also increase the cognitive load of reading the code.\n\nIf an import statement is used to check for the availability or existence\nof a module, consider using `importlib.util.find_spec` instead.\n\nIf an import statement is used to re-export a symbol as part of a module's\npublic interface, consider using a \"redundant\" import alias, which\ninstructs Ruff (and other tools) to respect the re-export, and avoid\nmarking it as unused, as in:\n\n```python\nfrom module import member as member\n```\n\nAlternatively, you can use `__all__` to declare a symbol as part of the module's\ninterface, as in:\n\n```python\n# __init__.py\nimport some_module\n\n__all__ = [\"some_module\"]\n```\n\n## Preview\nWhen [preview] is enabled (and certain simplifying assumptions\nare met), we analyze all import statements for a given module\nwhen determining whether an import is used, rather than simply\nthe last of these statements. This can result in both different and\nmore import statements being marked as unused.\n\nFor example, if a module consists of\n\n```python\nimport a\nimport a.b\n```\n\nthen both statements are marked as unused under [preview], whereas\nonly the second is marked as unused under stable behavior.\n\nAs another example, if a module consists of\n\n```python\nimport a.b\nimport a\n\na.b.foo()\n```\n\nthen a diagnostic will only be emitted for the first line under [preview],\nwhereas a diagnostic would only be emitted for the second line under\nstable behavior.\n\nNote that this behavior is somewhat subjective and is designed\nto conform to the developer's intuition rather than Python's actual\nexecution. To wit, the statement `import a.b` automatically executes\n`import a`, so in some sense `import a` is _always_ redundant\nin the presence of `import a.b`.\n\n\n## Fix safety\n\nFixes to remove unused imports are safe, except in `__init__.py` files.\n\nApplying fixes to `__init__.py` files is currently in preview. The fix offered depends on the\ntype of the unused import. Ruff will suggest a safe fix to export first-party imports with\neither a redundant alias or, if already present in the file, an `__all__` entry. If multiple\n`__all__` declarations are present, Ruff will not offer a fix. Ruff will suggest an unsafe fix\nto remove third-party and standard library imports -- the fix is unsafe because the module's\ninterface changes.\n\nSee [this FAQ section](https://docs.astral.sh/ruff/faq/#how-does-ruff-determine-which-of-my-imports-are-first-party-third-party-etc)\nfor more details on how Ruff\ndetermines whether an import is first or third-party.\n\n## Example\n\n```python\nimport numpy as np # unused import\n\n\ndef area(radius):\n return 3.14 * radius**2\n```\n\nUse instead:\n\n```python\ndef area(radius):\n return 3.14 * radius**2\n```\n\nTo check the availability of a module, use `importlib.util.find_spec`:\n\n```python\nfrom importlib.util import find_spec\n\nif find_spec(\"numpy\") is not None:\n print(\"numpy is installed\")\nelse:\n print(\"numpy is not installed\")\n```\n\n## Options\n- `lint.ignore-init-module-imports`\n- `lint.pyflakes.allowed-unused-imports`\n\n## References\n- [Python documentation: `import`](https://docs.python.org/3/reference/simple_stmts.html#the-import-statement)\n- [Python documentation: `importlib.util.find_spec`](https://docs.python.org/3/library/importlib.html#importlib.util.find_spec)\n- [Typing documentation: interface conventions](https://typing.python.org/en/latest/spec/distributing.html#library-interface-public-and-private-symbols)\n\n[preview]: https://docs.astral.sh/ruff/preview/\n",
"preview": false,
"status": {

View File

@@ -63,12 +63,7 @@ fn generate_markdown() -> String {
let _ = writeln!(&mut output, "# Rules\n");
let mut lints: Vec<_> = registry.lints().iter().collect();
lints.sort_by(|a, b| {
a.default_level()
.cmp(&b.default_level())
.reverse()
.then_with(|| a.name().cmp(&b.name()))
});
lints.sort_by_key(|a| a.name());
for lint in lints {
let _ = writeln!(&mut output, "## `{rule_name}`\n", rule_name = lint.name());
@@ -119,7 +114,7 @@ fn generate_markdown() -> String {
let _ = writeln!(
&mut output,
r#"<small>
Default level: <a href="../rules.md#rule-levels" title="This lint has a default level of '{level}'."><code>{level}</code></a> ·
Default level: <a href="../../rules#rule-levels" title="This lint has a default level of '{level}'."><code>{level}</code></a> ·
{status_text} ·
<a href="https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20{encoded_name}" target="_blank">Related issues</a> ·
<a href="https://github.com/astral-sh/ruff/blob/main/{file}#L{line}" target="_blank">View source</a>

View File

@@ -35,7 +35,7 @@ use crate::{FixAvailability, Violation};
/// fab_auth_manager_app = FabAuthManager().get_fastapi_app()
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct Airflow3MovedToProvider<'a> {
deprecated: QualifiedName<'a>,
replacement: ProviderReplacement,

View File

@@ -41,7 +41,7 @@ use ruff_text_size::TextRange;
/// yesterday = today - timedelta(days=1)
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct Airflow3Removal {
deprecated: String,
replacement: Replacement,

View File

@@ -51,7 +51,7 @@ use ruff_text_size::TextRange;
/// )
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct Airflow3SuggestedToMoveToProvider<'a> {
deprecated: QualifiedName<'a>,
replacement: ProviderReplacement,

View File

@@ -37,7 +37,7 @@ use ruff_text_size::TextRange;
/// Asset(uri="test://test/")
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct Airflow3SuggestedUpdate {
deprecated: String,
replacement: Replacement,

View File

@@ -30,7 +30,7 @@ use crate::rules::eradicate::detection::comment_contains_code;
///
/// [#4845]: https://github.com/astral-sh/ruff/issues/4845
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.145", safety = "display-only")]
#[violation_metadata(stable_since = "v0.0.145")]
pub(crate) struct CommentedOutCode;
impl Violation for CommentedOutCode {

View File

@@ -79,7 +79,7 @@ use ruff_python_ast::PythonVersion;
/// [typing-annotated]: https://docs.python.org/3/library/typing.html#typing.Annotated
/// [typing-extensions]: https://typing-extensions.readthedocs.io/en/stable/
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.8.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.8.0")]
pub(crate) struct FastApiNonAnnotatedDependency {
py_version: PythonVersion,
}

View File

@@ -59,7 +59,7 @@ use crate::{AlwaysFixableViolation, Fix};
/// return item
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.8.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.8.0")]
pub(crate) struct FastApiRedundantResponseModel;
impl AlwaysFixableViolation for FastApiRedundantResponseModel {

View File

@@ -64,7 +64,7 @@ use crate::{FixAvailability, Violation};
/// This rule's fix is marked as unsafe, as modifying a function signature can
/// change the behavior of the code.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.10.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.10.0")]
pub(crate) struct FastApiUnusedPathParameter {
arg_name: String,
function_name: String,

View File

@@ -241,7 +241,7 @@ impl Violation for MissingTypeCls {
///
/// - `lint.typing-extensions`
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.105", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.105")]
pub(crate) struct MissingReturnTypeUndocumentedPublicFunction {
name: String,
annotation: Option<String>,
@@ -295,7 +295,7 @@ impl Violation for MissingReturnTypeUndocumentedPublicFunction {
///
/// - `lint.typing-extensions`
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.105", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.105")]
pub(crate) struct MissingReturnTypePrivateFunction {
name: String,
annotation: Option<String>,
@@ -352,7 +352,7 @@ impl Violation for MissingReturnTypePrivateFunction {
/// self.x = x
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.105", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.105")]
pub(crate) struct MissingReturnTypeSpecialMethod {
name: String,
annotation: Option<String>,
@@ -400,7 +400,7 @@ impl Violation for MissingReturnTypeSpecialMethod {
/// return 1
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.105", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.105")]
pub(crate) struct MissingReturnTypeStaticMethod {
name: String,
annotation: Option<String>,
@@ -448,7 +448,7 @@ impl Violation for MissingReturnTypeStaticMethod {
/// return 1
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.105", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.105")]
pub(crate) struct MissingReturnTypeClassMethod {
name: String,
annotation: Option<String>,

View File

@@ -49,7 +49,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// )
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.5.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.5.0")]
pub(crate) struct AsyncZeroSleep {
module: AsyncModule,
}

View File

@@ -39,7 +39,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
///
/// This fix is marked as unsafe as it changes program behavior.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct LongSleepNotForever {
module: AsyncModule,
}

View File

@@ -38,7 +38,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// This rule's fix is marked as unsafe, as adding an `await` to a function
/// call changes its semantics and runtime behavior.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.5.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.5.0")]
pub(crate) struct TrioSyncCall {
method_name: MethodName,
}

View File

@@ -35,7 +35,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// ## References
/// - [Python documentation: `assert`](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.67", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.67")]
pub(crate) struct AssertFalse;
impl AlwaysFixableViolation for AssertFalse {

View File

@@ -48,7 +48,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// ## References
/// - [Python documentation: `getattr`](https://docs.python.org/3/library/functions.html#getattr)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.110", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.110")]
pub(crate) struct GetAttrWithConstant;
impl AlwaysFixableViolation for GetAttrWithConstant {

View File

@@ -43,7 +43,7 @@ use crate::{AlwaysFixableViolation, Applicability, Fix};
/// - [Python documentation: `map`](https://docs.python.org/3/library/functions.html#map)
/// - [Whats New in Python 3.14](https://docs.python.org/dev/whatsnew/3.14.html)
#[derive(ViolationMetadata)]
#[violation_metadata(preview_since = "0.13.2", safety = "unsafe")]
#[violation_metadata(preview_since = "0.13.2")]
pub(crate) struct MapWithoutExplicitStrict;
impl AlwaysFixableViolation for MapWithoutExplicitStrict {

View File

@@ -79,7 +79,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: Default Argument Values](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.92", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.92")]
pub(crate) struct MutableArgumentDefault;
impl Violation for MutableArgumentDefault {

View File

@@ -41,7 +41,7 @@ use crate::{checkers::ast::Checker, fix::edits::add_argument};
/// ## References
/// - [Python documentation: `warnings.warn`](https://docs.python.org/3/library/warnings.html#warnings.warn)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.257", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.257")]
pub(crate) struct NoExplicitStacklevel;
impl AlwaysFixableViolation for NoExplicitStacklevel {

View File

@@ -49,7 +49,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// ## References
/// - [Python documentation: `setattr`](https://docs.python.org/3/library/functions.html#setattr)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.111", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.111")]
pub(crate) struct SetAttrWithConstant;
impl AlwaysFixableViolation for SetAttrWithConstant {

View File

@@ -67,7 +67,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// - [Python documentation: `__getattr__`](https://docs.python.org/3/reference/datamodel.html#object.__getattr__)
/// - [Python documentation: `__call__`](https://docs.python.org/3/reference/datamodel.html#object.__call__)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.106", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.106")]
pub(crate) struct UnreliableCallableCheck;
impl Violation for UnreliableCallableCheck {

View File

@@ -35,7 +35,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [PEP 8: Naming Conventions](https://peps.python.org/pep-0008/#naming-conventions)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.84", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.84")]
pub(crate) struct UnusedLoopControlVariable {
/// The name of the loop control variable.
name: String,

View File

@@ -39,7 +39,7 @@ use crate::{AlwaysFixableViolation, Applicability, Fix};
/// ## References
/// - [Python documentation: `zip`](https://docs.python.org/3/library/functions.html#zip)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.167", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.167")]
pub(crate) struct ZipWithoutExplicitStrict;
impl AlwaysFixableViolation for ZipWithoutExplicitStrict {

View File

@@ -42,7 +42,7 @@ use crate::rules::flake8_comprehensions::fixes;
/// The fix is marked as safe for `list()` cases, as removing `list()` around
/// `sorted()` does not change the behavior.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.73", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.73")]
pub(crate) struct UnnecessaryCallAroundSorted {
func: UnnecessaryFunction,
}

View File

@@ -40,7 +40,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// ## Options
/// - `lint.flake8-comprehensions.allow-dict-calls-with-keyword-arguments`
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.61", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.61")]
pub(crate) struct UnnecessaryCollectionCall {
kind: Collection,
}

View File

@@ -57,7 +57,7 @@ use crate::rules::flake8_comprehensions::fixes;
///
/// Additionally, this fix may drop comments when rewriting the comprehension.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.73", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.73")]
pub(crate) struct UnnecessaryComprehension {
kind: ComprehensionKind,
}

View File

@@ -67,7 +67,7 @@ use crate::{Edit, Fix, Violation};
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.262", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.262")]
pub(crate) struct UnnecessaryComprehensionInCall {
comprehension_kind: ComprehensionKind,
}

View File

@@ -49,7 +49,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: `dict.fromkeys`](https://docs.python.org/3/library/stdtypes.html#dict.fromkeys)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.10.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.10.0")]
pub(crate) struct UnnecessaryDictComprehensionForIterable {
is_value_none_literal: bool,
}

View File

@@ -48,7 +48,7 @@ use crate::rules::flake8_comprehensions::fixes;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.70", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.70")]
pub(crate) struct UnnecessaryDoubleCastOrProcess {
inner: String,
outer: String,

View File

@@ -32,7 +32,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.61", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.61")]
pub(crate) struct UnnecessaryGeneratorDict;
impl AlwaysFixableViolation for UnnecessaryGeneratorDict {

View File

@@ -42,7 +42,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.61", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.61")]
pub(crate) struct UnnecessaryGeneratorList {
short_circuit: bool,
}

View File

@@ -43,7 +43,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.61", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.61")]
pub(crate) struct UnnecessaryGeneratorSet {
short_circuit: bool,
}

View File

@@ -29,7 +29,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.73", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.73")]
pub(crate) struct UnnecessaryListCall;
impl AlwaysFixableViolation for UnnecessaryListCall {

View File

@@ -29,7 +29,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.58", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.58")]
pub(crate) struct UnnecessaryListComprehensionDict;
impl AlwaysFixableViolation for UnnecessaryListComprehensionDict {

View File

@@ -31,7 +31,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.58", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.58")]
pub(crate) struct UnnecessaryListComprehensionSet;
impl AlwaysFixableViolation for UnnecessaryListComprehensionSet {

View File

@@ -33,7 +33,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.61", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.61")]
pub(crate) struct UnnecessaryLiteralDict {
obj_type: LiteralKind,
}

View File

@@ -34,7 +34,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.61", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.61")]
pub(crate) struct UnnecessaryLiteralSet {
kind: UnnecessaryLiteral,
}

View File

@@ -35,7 +35,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.262", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.262")]
pub(crate) struct UnnecessaryLiteralWithinDictCall {
kind: DictKind,
}

View File

@@ -35,7 +35,7 @@ use crate::rules::flake8_comprehensions::helpers;
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.66", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.66")]
pub(crate) struct UnnecessaryLiteralWithinListCall {
kind: LiteralKind,
}

View File

@@ -48,7 +48,7 @@ use crate::rules::flake8_comprehensions::helpers;
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.66", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.66")]
pub(crate) struct UnnecessaryLiteralWithinTupleCall {
literal_kind: TupleLiteralKind,
}

View File

@@ -44,7 +44,7 @@ use crate::{FixAvailability, Violation};
/// This rule's fix is marked as unsafe, as it may occasionally drop comments
/// when rewriting the call. In most cases, though, comments will be preserved.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.74", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.74")]
pub(crate) struct UnnecessaryMap {
object_type: ObjectType,
}

View File

@@ -48,7 +48,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// RuntimeError: 'Some value' is incorrect
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.183", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.183")]
pub(crate) struct RawStringInException;
impl Violation for RawStringInException {
@@ -104,7 +104,7 @@ impl Violation for RawStringInException {
/// RuntimeError: 'Some value' is incorrect
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.183", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.183")]
pub(crate) struct FStringInException;
impl Violation for FStringInException {
@@ -161,7 +161,7 @@ impl Violation for FStringInException {
/// RuntimeError: 'Some value' is incorrect
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.183", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.183")]
pub(crate) struct DotFormatInException;
impl Violation for DotFormatInException {

View File

@@ -49,7 +49,7 @@ use crate::{AlwaysFixableViolation, Fix};
/// ## Options
/// - `target-version`
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.271", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.271")]
pub(crate) struct FutureRequiredTypeAnnotation {
reason: Reason,
}

View File

@@ -68,7 +68,7 @@ use crate::{AlwaysFixableViolation, Fix};
/// ## Options
/// - `target-version`
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.269", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.269")]
pub(crate) struct FutureRewritableTypeAnnotation {
name: String,
}

View File

@@ -51,7 +51,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// However, the issue is that you may often want to change semantics
/// by adding a missing comma.
#[derive(ViolationMetadata)]
#[violation_metadata(preview_since = "0.14.10", safety = "unsafe")]
#[violation_metadata(preview_since = "0.14.10")]
pub(crate) struct ImplicitStringConcatenationInCollectionLiteral;
impl Violation for ImplicitStringConcatenationInCollectionLiteral {

View File

@@ -35,7 +35,7 @@ use crate::renamer::Renamer;
/// - `lint.flake8-import-conventions.aliases`
/// - `lint.flake8-import-conventions.extend-aliases`
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.166", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.166")]
pub(crate) struct UnconventionalImportAlias {
name: String,
asname: String,

View File

@@ -42,7 +42,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
///
/// [Logger Objects]: https://docs.python.org/3/library/logging.html#logger-objects
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.2.0", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.2.0")]
pub(crate) struct DirectLoggerInstantiation;
impl Violation for DirectLoggerInstantiation {

View File

@@ -44,7 +44,7 @@ use crate::{Fix, FixAvailability, Violation};
/// ## Fix safety
/// The fix is always marked as unsafe, as it changes runtime behavior.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.12.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.12.0")]
pub(crate) struct ExcInfoOutsideExceptHandler;
impl Violation for ExcInfoOutsideExceptHandler {

View File

@@ -45,7 +45,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
///
/// [logging documentation]: https://docs.python.org/3/library/logging.html#logger-objects
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.2.0", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.2.0")]
pub(crate) struct InvalidGetLoggerArgument;
impl Violation for InvalidGetLoggerArgument {

View File

@@ -44,7 +44,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
///
/// [The documentation]: https://docs.python.org/3/library/logging.html#logging.exception
#[derive(ViolationMetadata)]
#[violation_metadata(preview_since = "0.9.5", safety = "unsafe")]
#[violation_metadata(preview_since = "0.9.5")]
pub(crate) struct LogExceptionOutsideExceptHandler;
impl Violation for LogExceptionOutsideExceptHandler {

View File

@@ -35,7 +35,7 @@ use crate::{AlwaysFixableViolation, Fix};
/// This fix is always marked as unsafe since we cannot know
/// for certain which assignment was intended.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct DuplicateClassFieldDefinition {
name: String,
}

View File

@@ -49,7 +49,7 @@ use crate::{Edit, Fix};
/// - [Python documentation: `str.startswith`](https://docs.python.org/3/library/stdtypes.html#str.startswith)
/// - [Python documentation: `str.endswith`](https://docs.python.org/3/library/stdtypes.html#str.endswith)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.243", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.243")]
pub(crate) struct MultipleStartsEndsWith {
attr: String,
}

View File

@@ -70,7 +70,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
/// - [Python documentation: Dictionary displays](https://docs.python.org/3/reference/expressions.html#dictionary-displays)
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.231", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.231")]
pub(crate) struct UnnecessaryDictKwargs;
impl Violation for UnnecessaryDictKwargs {

View File

@@ -57,7 +57,7 @@ use crate::{Edit, Fix};
/// ## References
/// - [Python documentation: The `pass` statement](https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct UnnecessaryPlaceholder {
kind: Placeholder,
}

View File

@@ -37,10 +37,11 @@ use crate::{Fix, FixAvailability, Violation};
/// import logging
///
/// logging.basicConfig(level=logging.INFO)
/// logger = logging.getLogger(__name__)
///
///
/// def sum_less_than_four(a, b):
/// logging.debug("Calling sum_less_than_four")
/// logger.debug("Calling sum_less_than_four")
/// return a + b < 4
/// ```
///
@@ -48,7 +49,7 @@ use crate::{Fix, FixAvailability, Violation};
/// This rule's fix is marked as unsafe, as it will remove `print` statements
/// that are used beyond debugging purposes.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.57", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.57")]
pub(crate) struct Print;
impl Violation for Print {
@@ -98,7 +99,7 @@ impl Violation for Print {
/// This rule's fix is marked as unsafe, as it will remove `pprint` statements
/// that are used beyond debugging purposes.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.57", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.57")]
pub(crate) struct PPrint;
impl Violation for PPrint {

View File

@@ -89,7 +89,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
/// [typing_TypeVar]: https://docs.python.org/3/library/typing.html#typing.TypeVar
/// [typing_extensions]: https://typing-extensions.readthedocs.io/en/latest/
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.283", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.283")]
pub(crate) struct CustomTypeVarForSelf {
typevar_name: String,
}

View File

@@ -27,7 +27,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// def func(param: int) -> str: ...
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.253", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.253")]
pub(crate) struct DocstringInStub;
impl AlwaysFixableViolation for DocstringInStub {

View File

@@ -40,7 +40,7 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix};
/// ## References
/// - [Python documentation: `typing.Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.6.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.6.0")]
pub(crate) struct DuplicateLiteralMember {
duplicate_name: String,
}

View File

@@ -37,7 +37,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: `typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.262", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.262")]
pub(crate) struct DuplicateUnionMember {
duplicate_name: String,
}

View File

@@ -84,7 +84,7 @@ use crate::{Fix, FixAvailability, Violation};
/// [1]: https://github.com/python/cpython/issues/106102
/// [MRO]: https://docs.python.org/3/glossary.html#term-method-resolution-order
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct GenericNotLastBaseClass;
impl Violation for GenericNotLastBaseClass {

View File

@@ -113,7 +113,7 @@ use ruff_text_size::Ranged;
///
/// [PEP 673]: https://peps.python.org/pep-0673/#valid-locations-for-self
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.271", safety = "display-only")]
#[violation_metadata(stable_since = "v0.0.271")]
pub(crate) struct NonSelfReturnType {
class_name: String,
method_name: String,

View File

@@ -49,7 +49,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Typing documentation: Legal parameters for `Literal` at type check time](https://typing.python.org/en/latest/spec/literal.html#legal-parameters-for-literal-at-type-check-time)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.13.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.13.0")]
pub(crate) struct RedundantNoneLiteral {
union_kind: UnionKind,
}

View File

@@ -53,7 +53,7 @@ use super::generate_union_fix;
///
/// [typing specification]: https://typing.python.org/en/latest/spec/special-types.html#special-cases-for-float-and-complex
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.279", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.279")]
pub(crate) struct RedundantNumericUnion {
redundancy: Redundancy,
}

View File

@@ -40,7 +40,7 @@ use crate::{Applicability, Fix, FixAvailability, Violation};
/// `import foo as foo` alias, or are imported via a `*` import. As such, the
/// fix is marked as safe in more cases for `.pyi` files.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.271", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.271")]
pub(crate) struct UnaliasedCollectionsAbcSetImport;
impl Violation for UnaliasedCollectionsAbcSetImport {

View File

@@ -47,7 +47,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: `typing.Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.278", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.278")]
pub(crate) struct UnnecessaryLiteralUnion {
members: Vec<String>,
}

View File

@@ -32,7 +32,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
/// Note that while the fix may flatten nested unions into a single top-level union,
/// the semantics of the annotation will remain unchanged.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.283", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.283")]
pub(crate) struct UnnecessaryTypeUnion {
members: Vec<Name>,
union_kind: UnionKind,

View File

@@ -30,7 +30,7 @@ use crate::{Fix, FixAvailability, Violation};
/// The fix is always marked as unsafe, as it would break your code if the type
/// variable is imported by another module.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.281", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.281")]
pub(crate) struct UnusedPrivateTypeVar {
type_var_like_name: String,
type_var_like_kind: String,

View File

@@ -61,7 +61,7 @@ use super::unittest_assert::UnittestAssert;
/// assert not something_else
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestCompositeAssertion;
impl Violation for PytestCompositeAssertion {
@@ -191,7 +191,7 @@ impl Violation for PytestAssertAlwaysFalse {
/// ## References
/// - [`pytest` documentation: Assertion introspection details](https://docs.pytest.org/en/7.1.x/how-to/assert.html#assertion-introspection-details)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestUnittestAssertion {
assertion: String,
}
@@ -346,7 +346,7 @@ pub(crate) fn unittest_assertion(
/// ## References
/// - [`pytest` documentation: Assertions about expected exceptions](https://docs.pytest.org/en/latest/how-to/assert.html#assertions-about-expected-exceptions)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.285", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.285")]
pub(crate) struct PytestUnittestRaisesAssertion {
assertion: String,
}

View File

@@ -80,7 +80,7 @@ use crate::rules::flake8_pytest_style::helpers::{
/// ## References
/// - [`pytest` documentation: API Reference: Fixtures](https://docs.pytest.org/en/latest/reference/reference.html#fixtures-api)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestFixtureIncorrectParenthesesStyle {
expected: Parentheses,
actual: Parentheses,
@@ -174,7 +174,7 @@ impl Violation for PytestFixturePositionalArgs {
/// ## References
/// - [`pytest` documentation: `@pytest.fixture` functions](https://docs.pytest.org/en/latest/reference/reference.html#pytest-fixture)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestExtraneousScopeFunction;
impl AlwaysFixableViolation for PytestExtraneousScopeFunction {

View File

@@ -64,7 +64,7 @@ use crate::rules::flake8_pytest_style::helpers::{Parentheses, get_mark_decorator
/// ## References
/// - [`pytest` documentation: Marks](https://docs.pytest.org/en/latest/reference/reference.html#marks)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestIncorrectMarkParenthesesStyle {
mark_name: String,
expected_parens: Parentheses,
@@ -120,7 +120,7 @@ impl AlwaysFixableViolation for PytestIncorrectMarkParenthesesStyle {
/// ## References
/// - [`pytest` documentation: `pytest.mark.usefixtures`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-mark-usefixtures)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestUseFixturesWithoutParameters;
impl AlwaysFixableViolation for PytestUseFixturesWithoutParameters {

View File

@@ -65,7 +65,7 @@ use crate::rules::flake8_pytest_style::types;
/// ## References
/// - [`pytest` documentation: How to parametrize fixtures and test functions](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestParametrizeNamesWrongType {
single_argument: bool,
expected: types::ParametrizeNameType,
@@ -200,7 +200,7 @@ impl Violation for PytestParametrizeNamesWrongType {
/// ## References
/// - [`pytest` documentation: How to parametrize fixtures and test functions](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct PytestParametrizeValuesWrongType {
values: types::ParametrizeValuesType,
row: types::ParametrizeValuesRowType,
@@ -265,7 +265,7 @@ impl Violation for PytestParametrizeValuesWrongType {
/// ## References
/// - [`pytest` documentation: How to parametrize fixtures and test functions](https://docs.pytest.org/en/latest/how-to/parametrize.html#pytest-mark-parametrize)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.285", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.285")]
pub(crate) struct PytestDuplicateParametrizeTestCases {
index: usize,
}

View File

@@ -31,7 +31,7 @@ use ruff_text_size::Ranged;
/// ## References
/// - [Original Pytest issue](https://github.com/pytest-dev/pytest/issues/12693)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.12.0", safety = "display-only")]
#[violation_metadata(stable_since = "0.12.0")]
pub(crate) struct PytestParameterWithDefaultArgument {
parameter_name: String,
}

View File

@@ -43,7 +43,7 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix};
/// ## References
/// - [Python documentation: The `raise` statement](https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.239", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.239")]
pub(crate) struct UnnecessaryParenOnRaiseException;
impl AlwaysFixableViolation for UnnecessaryParenOnRaiseException {

View File

@@ -56,7 +56,7 @@ use crate::rules::flake8_return::visitor::{ReturnVisitor, Stack};
/// This rule's fix is marked as unsafe for cases in which comments would be
/// dropped from the `return` statement.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.154", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.154")]
pub(crate) struct UnnecessaryReturnNone;
impl AlwaysFixableViolation for UnnecessaryReturnNone {
@@ -137,7 +137,7 @@ impl AlwaysFixableViolation for ImplicitReturnValue {
/// return None
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.154", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.154")]
pub(crate) struct ImplicitReturn;
impl AlwaysFixableViolation for ImplicitReturn {
@@ -173,7 +173,7 @@ impl AlwaysFixableViolation for ImplicitReturn {
/// return 1
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.154", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.154")]
pub(crate) struct UnnecessaryAssign {
name: String,
}

View File

@@ -45,7 +45,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.212", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.212")]
pub(crate) struct DuplicateIsinstanceCall {
name: Option<String>,
}
@@ -94,7 +94,7 @@ impl Violation for DuplicateIsinstanceCall {
/// ## References
/// - [Python documentation: Membership test operations](https://docs.python.org/3/reference/expressions.html#membership-test-operations)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.213", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.213")]
pub(crate) struct CompareWithTuple {
replacement: String,
}
@@ -128,7 +128,7 @@ impl AlwaysFixableViolation for CompareWithTuple {
/// ## References
/// - [Python documentation: Boolean operations](https://docs.python.org/3/reference/expressions.html#boolean-operations)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.211", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.211")]
pub(crate) struct ExprAndNotExpr {
name: String,
}
@@ -161,7 +161,7 @@ impl AlwaysFixableViolation for ExprAndNotExpr {
/// ## References
/// - [Python documentation: Boolean operations](https://docs.python.org/3/reference/expressions.html#boolean-operations)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.211", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.211")]
pub(crate) struct ExprOrNotExpr {
name: String,
}
@@ -214,7 +214,7 @@ pub(crate) enum ContentAround {
/// a = x or [1]
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct ExprOrTrue {
expr: String,
remove: ContentAround,
@@ -267,7 +267,7 @@ impl AlwaysFixableViolation for ExprOrTrue {
/// a = x and []
/// ```
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.208", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.208")]
pub(crate) struct ExprAndFalse {
expr: String,
remove: ContentAround,

View File

@@ -41,7 +41,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: `os.environ`](https://docs.python.org/3/library/os.html#os.environ)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.218", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.218")]
pub(crate) struct UncapitalizedEnvironmentVariables {
expected: SourceCodeSnippet,
actual: SourceCodeSnippet,

View File

@@ -37,7 +37,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.214", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.214")]
pub(crate) struct IfExprWithTrueFalse {
is_compare: bool,
}
@@ -86,7 +86,7 @@ impl Violation for IfExprWithTrueFalse {
/// ## References
/// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.214", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.214")]
pub(crate) struct IfExprWithFalseTrue;
impl AlwaysFixableViolation for IfExprWithFalseTrue {
@@ -120,7 +120,7 @@ impl AlwaysFixableViolation for IfExprWithFalseTrue {
/// ## References
/// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.214", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.214")]
pub(crate) struct IfExprWithTwistedArms {
expr_body: String,
expr_else: String,

View File

@@ -33,7 +33,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
/// ## References
/// - [Python documentation: Comparisons](https://docs.python.org/3/reference/expressions.html#comparisons)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.213", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.213")]
pub(crate) struct NegateEqualOp {
left: String,
right: String,
@@ -76,7 +76,7 @@ impl AlwaysFixableViolation for NegateEqualOp {
/// ## References
/// - [Python documentation: Comparisons](https://docs.python.org/3/reference/expressions.html#comparisons)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.213", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.213")]
pub(crate) struct NegateNotEqualOp {
left: String,
right: String,

View File

@@ -46,7 +46,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// - [Python documentation: The `if` statement](https://docs.python.org/3/reference/compound_stmts.html#the-if-statement)
/// - [Python documentation: Boolean operations](https://docs.python.org/3/reference/expressions.html#boolean-operations)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.211", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.211")]
pub(crate) struct CollapsibleIf;
impl Violation for CollapsibleIf {

View File

@@ -53,7 +53,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: Mapping Types](https://docs.python.org/3/library/stdtypes.html#mapping-types-dict)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.219", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.219")]
pub(crate) struct IfElseBlockInsteadOfDictGet {
contents: String,
}

View File

@@ -61,7 +61,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// [code coverage]: https://github.com/nedbat/coveragepy/issues/509
/// [pycodestyle.max-line-length]: https://docs.astral.sh/ruff/settings/#lint_pycodestyle_max-line-length
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.213", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.213")]
pub(crate) struct IfElseBlockInsteadOfIfExp {
/// The ternary or binary expression to replace the `if`-`else`-block.
contents: String,

View File

@@ -38,7 +38,7 @@ use crate::{Applicability, Edit};
/// ## References
/// - [Python documentation: Mapping Types](https://docs.python.org/3/library/stdtypes.html#mapping-types-dict)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.176", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.176")]
pub(crate) struct InDictKeys {
operator: String,
}

View File

@@ -56,7 +56,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.214", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.214")]
pub(crate) struct NeedlessBool {
condition: Option<SourceCodeSnippet>,
negate: bool,

View File

@@ -44,7 +44,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// - [Python documentation: `any`](https://docs.python.org/3/library/functions.html#any)
/// - [Python documentation: `all`](https://docs.python.org/3/library/functions.html#all)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.211", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.211")]
pub(crate) struct ReimplementedBuiltin {
replacement: String,
}

View File

@@ -47,7 +47,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
/// ## References
/// - [Python documentation: `str.split`](https://docs.python.org/3/library/stdtypes.html#str.split)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.10.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.10.0")]
pub(crate) struct SplitStaticString {
method: Method,
}

View File

@@ -43,7 +43,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// - [Python documentation: `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
/// - [a simpler `try`/`except` (and why maybe shouldn't)](https://www.youtube.com/watch?v=MZAJ8qnC7mk)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.211", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.211")]
pub(crate) struct SuppressibleException {
exception: String,
}

View File

@@ -46,7 +46,7 @@ use crate::rules::flake8_tidy_imports::settings::Strictness;
///
/// [PEP 8]: https://peps.python.org/pep-0008/#imports
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.169", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.169")]
pub(crate) struct RelativeImports {
strictness: Strictness,
}

View File

@@ -43,7 +43,7 @@ use crate::{AlwaysFixableViolation, Fix};
/// This fix is safe as long as the type expression doesn't span multiple
/// lines and includes comments on any of the lines apart from the last one.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.10.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.10.0")]
pub(crate) struct RuntimeCastValue;
impl AlwaysFixableViolation for RuntimeCastValue {

View File

@@ -54,7 +54,7 @@ use crate::{Fix, FixAvailability, Violation};
/// ## References
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.8.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.8.0")]
pub(crate) struct RuntimeImportInTypeCheckingBlock {
qualified_name: String,
strategy: Strategy,

View File

@@ -49,7 +49,7 @@ use ruff_python_ast::token::parenthesized_range;
///
/// [PEP 613]: https://peps.python.org/pep-0613/
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.10.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.10.0")]
pub(crate) struct UnquotedTypeAlias;
impl Violation for UnquotedTypeAlias {
@@ -134,7 +134,7 @@ impl Violation for UnquotedTypeAlias {
/// [PYI020]: https://docs.astral.sh/ruff/rules/quoted-annotation-in-stub/
/// [UP037]: https://docs.astral.sh/ruff/rules/quoted-annotation/
#[derive(ViolationMetadata)]
#[violation_metadata(preview_since = "0.8.1", safety = "unsafe")]
#[violation_metadata(preview_since = "0.8.1")]
pub(crate) struct QuotedTypeAlias;
impl AlwaysFixableViolation for QuotedTypeAlias {

View File

@@ -81,7 +81,7 @@ use crate::{Fix, FixAvailability, Violation};
/// ## References
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.8.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.8.0")]
pub(crate) struct TypingOnlyFirstPartyImport {
qualified_name: String,
}
@@ -164,7 +164,7 @@ impl Violation for TypingOnlyFirstPartyImport {
/// ## References
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.8.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.8.0")]
pub(crate) struct TypingOnlyThirdPartyImport {
qualified_name: String,
}
@@ -247,7 +247,7 @@ impl Violation for TypingOnlyThirdPartyImport {
/// ## References
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.8.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.8.0")]
pub(crate) struct TypingOnlyStandardLibraryImport {
qualified_name: String,
}

View File

@@ -57,7 +57,7 @@ use ruff_text_size::Ranged;
///
/// No fix is offered if the suffix `"."` is given, since the intent is unclear.
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "0.10.0", safety = "unsafe")]
#[violation_metadata(stable_since = "0.10.0")]
pub(crate) struct InvalidPathlibWithSuffix {
single_dot: bool,
}

View File

@@ -51,7 +51,7 @@ use crate::{FixAvailability, Violation};
/// - [Why you should be using pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/)
/// - [No really, pathlib is great](https://treyhunner.com/2019/01/no-really-pathlib-is-great/)
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.231", safety = "unsafe")]
#[violation_metadata(stable_since = "v0.0.231")]
pub(crate) struct OsGetcwd;
impl Violation for OsGetcwd {

Some files were not shown because too many files have changed in this diff Show More