Skip to content

SIM108 autofix produces code that breaks E501 #1766

@Czaki

Description

@Czaki

When bumpy ruff from 207 to 217 (If I correctly check, the problem was introduced in 213) I got multiple autofixes from SIM108 that led to multiple errors reports from E501 as it creates very long lines (always creates single line if)

4DNucleome/PartSeg#879

Sample diff

--- a/package/PartSeg/_launcher/check_version.py
+++ b/package/PartSeg/_launcher/check_version.py
@@ -67,24 +67,7 @@ class CheckVersionThread(QThread):
         my_version = packaging.version.parse(self.base_release)
         remote_version = packaging.version.parse(self.release)
         if remote_version > my_version:
-            if getattr(sys, "frozen", False):
-                message = QMessageBox(
-                    QMessageBox.Information,
-                    "New release",
-                    f"You use outdated version of PartSeg. "
-                    f"Your version is {my_version} and current is {remote_version}. "
-                    f"You can download next release form {self.url}",
-                    QMessageBox.Ok | QMessageBox.Ignore,
-                )
-            else:
-                message = QMessageBox(
-                    QMessageBox.Information,
-                    "New release",
-                    f"You use outdated version of PartSeg. "
-                    f"Your version is {my_version} and current is {remote_version}. "
-                    "You can update it from pypi (pip install -U PartSeg)",
-                    QMessageBox.Ok | QMessageBox.Ignore,
-                )
+            message = QMessageBox(QMessageBox.Information, "New release", f"You use outdated version of PartSeg. Your version is {my_version} and current is {remote_version}. You can download next release form {self.url}", QMessageBox.Ok | QMessageBox.Ignore) if getattr(sys, "frozen", False) else QMessageBox(QMessageBox.Information, "New release", f"You use outdated version of PartSeg. Your version is {my_version} and current is {remote_version}. You can update it from pypi (pip install -U PartSeg)", QMessageBox.Ok | QMessageBox.Ignore)

For me, at least SIM108 should create E501 compatible code or even not fix it if the line is too long (as it will reduce readability).

In this example, even black cannot help as it concatenates strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions