Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint

on:
pull_request:
branches:
- master
push:
branches:
- master

env:
OV_BRANCH: master

jobs:
lint:
name: Lint Changed Files
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash

steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Run pre-commit on changed files
uses: pre-commit/[email protected]
with:
extra_args: --from-ref origin/${{ github.base_ref || 'master' }} --to-ref HEAD
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Am I right that it would be required to fix linting issues for any changed files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, only for changed ones.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So If I change 2 lines in several hundred loc file I would be required to fix lint for the whole file. Then feature changes would endup hidden in the linting changes. Is it correct?

Copy link
Contributor Author

@sgonorov sgonorov Nov 13, 2025

Choose a reason for hiding this comment

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

Yes, that's the way. We can't partially format file sadly.
But for now it's mostly whitespaces as a starting point so it won't affect much. Later I'll try to make a separate PRs with properly formatted files and new formatters/linters introduction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, for python there's a formatter called Darker which is compatible with Ruff format, but applies changes only to changed lines. When we get to it, maybe we'll use it instead of simply enabling Ruff across the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It ignores python files. I can add CPP-related file to exception for now too if needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What "it" refers to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whitespace hook - for now it ignores only Pyhton files. We can add cpp files also.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Add cpp to fix #3008 (comment) Any reason not to do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added. Then i'll create some migratiion PRs where fix all the whitespaces and remove these ignores.

- repo: meta
hooks:
- id: identity
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: '\.(py|c|cpp|h|hpp)$'
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- id: check-symlinks
- id: detect-private-key
- id: mixed-line-ending
args: ["--fix=lf"]
- id: check-ast
- id: check-yaml
- id: check-toml
- id: check-added-large-files
args: ["--maxkb=1000"]
- repo: https://github.com/akaihola/darker
rev: v3.0.0
hooks:
- id: darker
args: ["--formatter=ruff"]
additional_dependencies:
- ruff==0.14.4
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,16 @@ requires = [
"cmake~=3.24.0; platform_system == 'Darwin' and platform_machine == 'arm64'",
]
build-backend = "py_build_cmake.build"

[tool.ruff]
line-length = 120
indent-width = 4
target-version = "py310"

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
docstring-code-format = false
docstring-code-line-length = "dynamic"
Loading