Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when quoting annotations #11449

Closed
thejcannon opened this issue May 16, 2024 · 7 comments · Fixed by #11452
Closed

Panic when quoting annotations #11449

thejcannon opened this issue May 16, 2024 · 7 comments · Fixed by #11452
Assignees
Labels
bug Something isn't working

Comments

@thejcannon
Copy link
Contributor

thejcannon commented May 16, 2024

Version: 0.4.4
Command: ruff check --fix --unsafe-fixes foo.py

I whittled my repro down to:

from .t import RO, RP
from .urs import UR


class MUR(UR):
    def cr(self) -> RO | list[RP]:
        pass

My config is:

[lint]
select = ["TCH"]

[lint.flake8-type-checking]
quote-annotations = true

Stack is:

panicked at /Users/runner/work/ruff/ruff/crates/ruff_text_size/src/range.rs:48:9:
assertion failed: start.raw <= end.raw
Backtrace:    0: std::backtrace::Backtrace::force_capture
   1: <ruff::panic::PanicError as core::fmt::Display>::fmt
   2: std::panicking::rust_panic_with_hook
   3: <std::panicking::begin_panic_handler::StaticStrPayload as core::panic::PanicPayload>::take_box
   4: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic
   8: ruff_linter::rules::tryceratops::rules::verbose_raise::<impl core::convert::From<ruff_linter::rules::tryceratops::rules::verbose_raise::VerboseRaise> for ruff_diagnostics::diagnostic::DiagnosticKind>::from
   9: ruff_linter::linter::lint_fix
  10: <ruff::diagnostics::FixMap as core::ops::arith::AddAssign>::add_assign
  11: ruff::resolve::resolve
  12: <ruff::panic::PanicError as core::fmt::Display>::fmt
  13: <ruff::cache::PackageCacheMap as ruff::cache::PackageCaches>::get
  14: <ruff::args::LogLevelArgs as clap_builder::derive::Args>::augment_args
  15: <ruff::diagnostics::FixMap as core::ops::arith::AddAssign>::add_assign
  16: <ruff::cache::PackageCacheMap as ruff::cache::PackageCaches>::get
  17: ruff::check
  18: ruff::run
  19: <ruff::cache::PackageCacheMap as ruff::cache::PackageCaches>::get
  20: _main
  21: _main
  22: std::rt::lang_start_internal
  23: _main
@trag1c
Copy link
Contributor

trag1c commented May 16, 2024

I can't seem to reproduce this on v0.4.4 🤔

@thejcannon
Copy link
Contributor Author

thejcannon commented May 16, 2024

I'm on 0.4.3, let me try 0.4.4
(Meant to put that in my OP)

@thejcannon
Copy link
Contributor Author

Yup! Works in 0.4.4. Nothing in the changelog sticks out to me, but oh well.

@thejcannon thejcannon closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
@thejcannon thejcannon reopened this May 16, 2024
@thejcannon
Copy link
Contributor Author

Whoops, spoke to soon. Got it on 0.4.4, I forgot to include CLI command.

ruff check --fix --unsafe-fixes

@trag1c
Copy link
Contributor

trag1c commented May 16, 2024

Yup, can reproduce now:

error: Panicked while linting foo.py: This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BLinter%20panic%5D

...with the relevant file contents, the `pyproject.toml` settings, and the following stack trace, we'd be very appreciative!

panicked at /Users/runner/work/ruff/ruff/crates/ruff_text_size/src/range.rs:48:9:
assertion failed: start.raw <= end.raw
Backtrace:    0: std::backtrace::Backtrace::force_capture
   1: <ruff::panic::PanicError as core::fmt::Display>::fmt
   2: std::panicking::rust_panic_with_hook
   3: <std::panicking::begin_panic_handler::StaticStrPayload as core::panic::PanicPayload>::take_box
   4: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::panicking::panic
   8: ruff_linter::rules::tryceratops::rules::verbose_raise::<impl core::convert::From<ruff_linter::rules::tryceratops::rules::verbose_raise::VerboseRaise> for ruff_diagnostics::diagnostic::DiagnosticKind>::from
   9: ruff_linter::linter::lint_fix
  10: <ruff::diagnostics::FixMap as core::ops::arith::AddAssign>::add_assign
  11: ruff::resolve::resolve
  12: <ruff::panic::PanicError as core::fmt::Display>::fmt
  13: <ruff::cache::PackageCacheMap as ruff::cache::PackageCaches>::get
  14: <ruff::args::LogLevelArgs as clap_builder::derive::Args>::augment_args
  15: <ruff::diagnostics::FixMap as core::ops::arith::AddAssign>::add_assign
  16: <ruff::cache::PackageCacheMap as ruff::cache::PackageCaches>::get
  17: ruff::check
  18: ruff::run
  19: <ruff::cache::PackageCacheMap as ruff::cache::PackageCaches>::get
  20: _main
  21: _main
  22: std::rt::lang_start_internal
  23: _main


All checks passed!

@charliermarsh
Copy link
Member

Thx.

@charliermarsh charliermarsh added the bug Something isn't working label May 16, 2024
@charliermarsh charliermarsh changed the title [Linter panic] Panic when quoting annotations May 16, 2024
@charliermarsh charliermarsh self-assigned this May 16, 2024
@charliermarsh
Copy link
Member

I see the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants