Refer thread
https://vyos.slack.com/archives/C071P6CUTAN/p1721729541294979
Reply…
Also send to vyos-codeql-implementation
vyos-codeql-implementation
zsdc and you
zsdc
🏠 Jul 23rd at 3:42 PM
Hi,
@Vijayakumar
!
I have one question for you.
We started implementing strict validation for the Python code, and one of the steps for it is validating all incoming new/changed code. More context and details here: https://vyos.dev/T6583
Would you be able to implement this extra check for PRs? An example of the integration is here: https://docs.astral.sh/ruff/integrations/#github-actions
We need to check only the modified Python code. I saw people do this with git diff and pipes or with https://github.com/akaihola/darker, but how it will be implemented is not a big deal - the main goal is to block a code not formatted according to our requirements.
Can you take a look at this?
Also sent to the channel
Vijayakumar
Aug 3rd at 8:49 PM
Hi
@zsdc
I have checked ruff as well as darker.
ruff doesn't have the support for linting/checking only the changed lines of git diff. we can pass the changed files to this, but it will check the entire file, not just the changes/diff. Refer
https://github.com/vyos/vyos-workflow-test-temp/actions/runs/10227777050/job/28299602699.
This is the open issue on ruff https://github.com/astral-sh/ruff/issues/1149, https://github.com/astral-sh/ruff/discussions/4049
darker has this support, checks only the diff. Refer
https://github.com/vyos/vyos-workflow-test-temp/actions/runs/10227570186/job/28299163706
But darker uses the black (doesn't support ruff)
So, i think we can proceed with using darker.
Please let me know. (edited)
zsdc
🏠 Aug 5th at 8:32 PM
Hi!
As I can see, ruff is supported as a linter:
https://github.com/akaihola/darker/commit/acb622567d1a26b0c6dcbb1b171c1c8340ee6c22
This is enough for us.
Vijayakumar
Aug 5th at 9:56 PM
Ok good find, i will check (edited)