Skip to content

Python Substring: infine loop using ruff v0.1.2 #8299

@bigluck

Description

@bigluck

Using ruff v0.1.2 and ruff-pre-commit v0.1.2, pre-commit fails with:

ruff.....................................................................Failed
- hook id: ruff
- exit code: 1

error: Failed to converge after 100 iterations.

This indicates a bug in Ruff. If you could open an issue at:

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

...quoting the contents of `my/service/folder/api_v0/router.py`, the rule codes E231, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

my/service/folder/api_v0/router.py:215:106: E231 Missing whitespace after ':'
Found 101 errors (100 fixed, 1 remaining).

The code is pretty straightforward:

from sqlalchemy.orm import DeclarativeBase

class Base(DeclarativeBase):
    pass

class MyClass(Base):
    file_uri: Mapped[str] = mapped_column(
        String(1024),
        nullable=False,
    )

...

def my_function(snapshot: MyClass):
    assert snapshot.file_uri is not None, f'Run "{req.run_id}" does not have a snapshot file.'
    snapshot_path = snapshot.file_uri[len(f's3://{self.s3_bucket_name}/'):]

Here my pyproject.toml settings:

[tool.mypy]
warn_return_any = true
warn_unused_configs = true

plugins = ["pydantic.mypy"]

# follow_imports = "silent"
warn_redundant_casts = true
warn_unused_ignores = true
disallow_any_generics = true
check_untyped_defs = true
no_implicit_reexport = true

# for strict mypy: (this is the tricky one :-))
disallow_untyped_defs = true

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true


[tool.coverage.run]
branch = true
omit = [".devenv/*", "stages/*", "tests/*", ".venv/*"]


[tool.coverage.report]


[tool.coverage.xml]
output = "cov.xml"


[tool.ruff]
# Enable Pyflakes and pycodestyle rules.
select = ["E", "F"]
# select = ["ALL"]
preview = true

# Never enforce `E501` (line length violations).
ignore = ["E501"]

# Always autofix, but never try to fix `F401` (unused imports).
fix = true
unfixable = ["F401"]


[tool.ruff.per-file-ignores]
# "__init__.py" = ["E402"]

It works when I set:

    snapshot_path = snapshot.file_uri[len(f's3://{self.s3_bucket_name}/'): len(snapshot.file_uri)]

but still, it wants a space between the first and the second length :/

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions