Skip to content

Update Ruff and Fix Linting #629

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

Merged
merged 36 commits into from
May 25, 2025
Merged

Update Ruff and Fix Linting #629

merged 36 commits into from
May 25, 2025

Conversation

NeffIsBack
Copy link
Member

@NeffIsBack NeffIsBack commented Apr 3, 2025

Description

The pinned ruff version is super old by now. This PR updates ruff to the newest version and fixes all new rules that have been selected.
This should probably be merged after 1.4.0 is released

Excluded Rules:

  • FURB: Makes code a lot more complicated
  • D413: Unnecessary newlines in docstrings
  • RUF059: Allow unused variables because it is good to know which values are unpacked from content
  • A004: It complains about sys.exit shadowing python build-in exit(), which we have explicitly chose not to use

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dploot, lsassy, etc)
  • LINTING

How Has This Been Tested?

coerce_plus and pfx auth were tested against GOAD, but before merging extensive testing should still be done.

Checklist:

  • I have ran Ruff against my changes (via poetry: poetry run python -m ruff check . --preview, use --fix to automatically fix what it can)
  • New and existing e2e tests pass locally with my changes
  • My code follows the style guidelines of this project (should be covered by Ruff above)
  • I have performed a self-review of my own code

@NeffIsBack NeffIsBack added enhancement New feature or request requires testing labels Apr 3, 2025
@Marshall-Hallenbeck
Copy link
Collaborator

I'll have to run FURB myself to see what changes it does, but from looking at it, it looks like its a good way to update old crappy code to modern Pythonic conventions.

@NeffIsBack
Copy link
Member Author

NeffIsBack commented Apr 3, 2025

I'll have to run FURB myself to see what changes it does, but from looking at it, it looks like its a good way to update old crappy code to modern Pythonic conventions.

Try it out, but i disabled 3 rules each after another, because imo they made the code much more complex and nonuniform.
E.g. this:
image
image

Not sure if using "Path" is much better when everyone is used to "open". Also half of the rules are "unstable", for now, so maybe not even here to stay?

@Marshall-Hallenbeck
Copy link
Collaborator

If they're considered "unstable" yeah, probably not a good idea to use them. Path is the new way to use files with Python, so we should move to that.

@NeffIsBack
Copy link
Member Author

If they're considered "unstable" yeah, probably not a good idea to use them. Path is the new way to use files with Python, so we should move to that.

Hmm okay maybe then it is worth to enable some of them. Haven't seen Path yet, but perhaps it's the way to go

@NeffIsBack
Copy link
Member Author

We should probably use PTH then as well.
However, that would be a lot to do :D

image

@NeffIsBack NeffIsBack marked this pull request as ready for review April 3, 2025 18:55
@NeffIsBack NeffIsBack added this to the v1.5.0 milestone Apr 3, 2025
@NeffIsBack
Copy link
Member Author

Let the test run, everything good so far except the pso module, but that hangs in main as well:
image

@NeffIsBack NeffIsBack merged commit 6a0a985 into main May 25, 2025
6 checks passed
@NeffIsBack NeffIsBack deleted the neff-update-ruff branch May 25, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants