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

FIX: ruff linting errors #829

Merged
merged 7 commits into from
Sep 16, 2024
Merged

Conversation

omar-abdelgawad
Copy link
Contributor

📢 Describe your changes

  • 📌 changes Summary
    • All ruff linting errors were fixed except in invesalius/net. The errors are listed below using ruff check --extend-exclude 'invesalius/net' --statistics
246     F821    [ ] undefined-name
157     F841    [*] unused-variable
102     F401    [ ] unused-import
 90     UP031   [*] printf-string-formatting
 55     UP032   [*] f-string
 23     E722    [ ] bare-except
 20     UP004   [*] useless-object-inheritance
 20     UP008   [*] super-call-with-parameters
 18     E402    [ ] module-import-not-at-top-of-file
 16     E711    [*] none-comparison
  9     UP015   [*] redundant-open-modes
  8     F811    [ ] redefined-while-unused
  5     E741    [ ] ambiguous-variable-name
  5     F405    [ ] undefined-local-with-import-star-usage
  5     UP034   [*] extraneous-parentheses
  4     UP009   [*] utf8-encoding-declaration
  4     UP027   [*] unpacked-list-comprehension
  3     E713    [*] not-in-test
  3     E731    [*] lambda-assignment
  3     UP024   [*] os-error-alias
  2     E712    [*] true-false-comparison
  2     E714    [*] not-is-test
  2     F403    [ ] undefined-local-with-import-star
  2     UP010   [*] unnecessary-future-import
  1     I001    [*] unsorted-imports
  1     E721    [ ] type-comparison
  • Removed old wxpython3 and python2 imports
  • Refactored small snippets of code to be type compliant such as using getattr and setattr instead of using exceptions.
  • Commented unused variables
  • Replaced format and percent formatting with f-strings
  • Replaced 1 and 0 with True and False for type compliance
  • Deleted unused variable references
-        self.blend = blend = vtkImageBlend()
+        self.blend = vtkImageBlend()
  • Replaced None equality with identity comparison
  • Replaced list comprehension with generator comprehension if it is immediately destructured
-            a, b, c = [j - i for i, j in zip(self.points[1], self.points[2])]
+            a, b, c = (j - i for i, j in zip(self.points[1], self.points[2]))
  • Removed inheritance from object

  • Replaced wx._core.wxAssertionError with wx.wxAssertionError

  • Replaced IOError with OSError

  • 🐞 Bug Fixes:

    • Corrected variable names
           def RightButton(self, evt):
    -        event.Skip()
    +        evt.Skip()
    • Replaced bare except: with except Exception:
    • imported missing imports (from invesalius.i18n import tr as _)

🧪 How to test this Pull Request

  1.   ruff check --extend-exclude 'invesalius/net'

@tfmoraes tfmoraes merged commit 875e0b6 into invesalius:master Sep 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants