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

Make the ruff pre-commit hook fix issues when possible #10181

Closed
RayBB opened this issue Dec 22, 2024 · 1 comment · Fixed by #10180
Closed

Make the ruff pre-commit hook fix issues when possible #10181

RayBB opened this issue Dec 22, 2024 · 1 comment · Fixed by #10180
Labels
Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Lead Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed]

Comments

@RayBB
Copy link
Collaborator

RayBB commented Dec 22, 2024

Proposal

scripts/expire_accounts.py:1:1: I001 [*] Import block is un-sorted or un-formatted
  |
1 | / from datetime import datetime, UTC
2 | | import web
3 | | 
4 | | 
5 | | def delete_old_links():
  | |_^ I001
6 |       for doc in web.ctx.site.store.values(type="account-link"):
7 |           expiry_date = datetime.strptime(doc["expires_on"], "%Y-%m-%dT%H:%M:%S.%f")
  |
  = help: Organize imports

Found 1 error.
[*] 1 fixable with the `--fix` option.

Can we add the --fix option to our import linting rule to fix some common errors?

~ Mek (in a Slack DM)

Justification

Breakdown

Requirements Checklist

  • [ ]

Related files

Stakeholders


Instructions for Contributors

Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.

@RayBB RayBB added Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed] Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Dec 22, 2024
@drona-gyawali
Copy link
Contributor

drona-gyawali commented Dec 23, 2024

Yes, successfully added and utilized the --fix option to address common linting errors. Initially, the imports in scripts/expire_accounts.py were flagged as unorganized. I configured ruff properly in pyproject.toml by using [tool.ruff.lint] for lint-specific rules. Afterward, I ran:

ruff check --fix scripts/expire_accounts.py

This resolved the issue by automatically organizing the imports. Additionally, we ensured the linting configurations in pyproject.toml followed best practices for clarity and maintainability.

This approach ensures smoother development workflows by reducing manual fixes and maintaining code quality consistently.
Screenshot 2024-12-23 165037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Lead Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Type: Feature Request Issue describes a feature or enhancement we'd like to implement. [managed]
Projects
None yet
2 participants