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
Collaborator

Choose a reason for hiding this comment

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

I guess whitespaces only rules are ok for now. But I'm not sure about more complex rules.
I see 3 options:

  1. Enable rules. Expect PRs to fix linting along with the feature changes.
    This would be unconvenient for both, reviewer and author. Especialy for external contributors. We could ask to fix linting in a separate first to split linting and feature changes. But still confusing for external contributors.
  2. Enable rule by rule with appropriate files linting fixes. I guess this is how you want to proceed.
  3. Enable rules and implement filter pattern to filter out not linted files. Then we could incrementially fix linting and update filter.

Any more ideas on this?
Do you want to proceed with option 2? If yes, maybe we could start with this plan in this PR and fix whitespaces?

Copy link
Collaborator

Choose a reason for hiding this comment

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

2 is the best

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added Darker and yes, path 2 is the good one. Whitespaces is in around 200+ files. So i'll make it as a separate PR after this one.

- repo: meta
hooks:
- id: identity
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: '\.py$'
- 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 = 100
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