Validate python code style of pull request lines only

Good code base style is the part of non-functional project's quality.

Style checks are usually performed in pull request (PR) publishing and reviewing processes. However, IDE or regular CLI tools shows style issues for whole file(s), without difference, who and when adds the code lines.

Here is the instruction how to use python linter on exact PR content only, not on all of the body of the affected file(s).

Install pylint:

~/WORK/sources/Bitbucket/atf(master)$ sudo pip3 install pylint

Collecting pylint
...
Installing collected packages: wrapt, typing-extensions, lazy-object-proxy, platformdirs, isort, astroid, pylint
Successfully installed astroid-2.8.0 isort-5.9.3 lazy-object-proxy-1.6.0 platformdirs-2.4.0 pylint-2.11.1 typing-extensions-3.10.0.2 wrapt-1.12.1

Install lint-diffs:

~/WORK/sources/Bitbucket/atf(master)$ sudo pip3 install lint-diffs

Collecting lint-diffs
...
Installing collected packages: unidiff, lint-diffs
Successfully installed lint-diffs-0.1.22 unidiff-0.7.0

Checkout to PR branch:

~/WORK/sources/Bitbucket/atf(master)$ git checkout DA-4321-refactor-function-service

Branch 'DA-4321-refactor-function-service' set up to track remote branch 'DA-4321-refactor-function-service' from 'origin'.
Switched to a new branch 'DA-4321-refactor-function-service'

(Optional step) Temporarily merge master, if master has been changed since you start your PR branch (this is required for to validate PR lines only, without lines of other author's recent master changes):

~/WORK/sources/Bitbucket/atf(DA-4321-refactor-function-service)$ git merge master

Auto-merging core/processors/master_processor.py
Merge made by the 'recursive' strategy.
 core/processors/master_processor.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Magic is here, lint-diffs does it (also, ignore some warnings):

~/WORK/sources/Bitbucket/atf(DA-4321-refactor-function-service)$ git diff master | lint-diffs | grep -v -e C0301 -e C0116 -e C0115 -e C0114

tests/services/test_function_service.py:176:70: R1734: Consider using [] instead of list() (use-list-literal)
tests/services/test_function_service.py:9:0: C0411: third party import "from mock import patch" should be placed before "from core.services.functions_service import FunctionService" (wrong-import-order)
tests/services/test_function_service.py:10:0: C0412: Imports from package core are not grouped (ungrouped-imports)
# ************* Module core.services.functions_service
core/services/functions_service.py:32:5: W0511: TODO: add more complex types (fixme)
core/services/functions_service.py:200:22: C0303: Trailing whitespace (trailing-whitespace)
core/services/functions_service.py:446:0: C0305: Trailing newlines (trailing-newlines)
core/services/functions_service.py:48:35: R1735: Consider using {} instead of dict() (use-dict-literal)
core/services/functions_service.py:72:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
core/services/functions_service.py:78:12: C0103: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
core/services/functions_service.py:79:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
core/services/functions_service.py:48:8: W0201: Attribute 'contracts_functions' defined outside __init__ (attribute-defined-outside-init)
core/services/functions_service.py:63:8: W0201: Attribute 'inaccurate_contracts' defined outside __init__ (attribute-defined-outside-init)
# ************* Module fixtures
tests/services/fixtures.py:120:21: W0621: Redefining name 'db_provider' from outer scope (line 103) (redefined-outer-name)
tests/services/fixtures.py:120:34: W0621: Redefining name 'testing_db' from outer scope (line 63) (redefined-outer-name)
tests/services/fixtures.py:121:4: W0621: Redefining name 'function_service' from outer scope (line 120) (redefined-outer-name)
tests/services/fixtures.py:120:21: W0613: Unused argument 'db_provider' (unused-argument)
core/domain/functions.py:45:0: C0305: Trailing newlines (trailing-newlines)
core/domain/functions.py:38:4: C0103: Attribute name "id" doesn't conform to snake_case naming style (invalid-name)
# ************* Module core.processors.master_processor
core/processors/master_processor.py:208:58: C0303: Trailing whitespace (trailing-whitespace)
core/processors/master_processor.py:212:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)

=== pylint: mine=79, always=0

Reject merge commit in local branch (required !!!only!!! in case of master merge step above has really happened:

~/WORK/sources/Bitbucket/atf(DA-4321-refactor-function-service)$ git reset --hard HEAD~1
HEAD is now at d3918386 simplify function validation

tiaf.jpg