Skip to content

Conversation

@roberto-arista
Copy link
Contributor

Hey!

Here's a PR with my implementation proposal for ruff in the drawBot codebase. In a nutshell:

  • it adds a lint.yml file with instructions to format the code and auto-commit it back to the codebase
  • therefore test.yml needs to start once the auto-commit is completed (workflow_run section)
  • it adds a ruff.toml configuration file
  • it adds the ruff-api package that allows calling ruff from the python codebase to substitute black (application menu > python > format code)

I've had mixed results with triggering one action from another when writing back some changes in the repo, we might explore different options eventually. Also, the ruff-api would like to have a filename to format the code (I guess for imports?), have a look at the FIXME here: drawBot/ui/drawBotController.py

That's it, let me know what you think!

👋

…to ruff

# Conflicts:
#	docs/conf.py
#	drawBot/context/tools/imageObject.py
#	scripting/imageObjectCodeExtractor.py
#	tests/testImageObject.py
@justvanrossum
Copy link
Collaborator

Thanks!

Not a big fan of autocommit, and I would prefer a pre-commit based approach that does apply fixes. What I do in other projects:

  • Use pre-commit (locally), that runs black and flake8, which will fix issues, but aborts the commit if it had to do anything
  • Use pre-commit also as a GHA step, that will fail if it has any complaints

Ideally I would like to see two separate PRs:

  1. Reformat + lint the entire code base
  2. Set up GHA / pre-commit to make sure the code base stays nicely formatted and lint-clean

@roberto-arista
Copy link
Contributor Author

on my way : )

@roberto-arista
Copy link
Contributor Author

I would convert this one to PR1 and open another one for GHA

Copy link
Collaborator

@justvanrossum justvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few minor comments. LGTM, apart from the test failure.

@roberto-arista
Copy link
Contributor Author

I'll wait for this one to be merged before working on the github actions logic.

Copy link
Collaborator

@justvanrossum justvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

justvanrossum added a commit that referenced this pull request Apr 25, 2025
@justvanrossum
Copy link
Collaborator

@typemytype, shall we merge soon? I fear it will cause merge conflicts if we don't. Case in point: #582.

@typemytype
Copy link
Owner

Sure, this is awesome! Is there a PR merge order?

@justvanrossum
Copy link
Collaborator

Is there a PR merge order?

No... In this case, If we merge PR A first, PR B will (likely) have a conflict. Maybe merge this one first.

@roberto-arista
Copy link
Contributor Author

im ooo, but I agree with Just, let's merge the linted code first, I'll work on the hook and workflow next week : )

@justvanrossum justvanrossum merged commit 4b42478 into typemytype:master Apr 25, 2025
1 check passed
@justvanrossum
Copy link
Collaborator

(Oooh we got lucky: there was no merge conflict!)

@typemytype
Copy link
Owner

thanks @roberto-arista !!

@roberto-arista
Copy link
Contributor Author

ty!

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.

3 participants