From 641e51d457a9f0427457521da6e157bfc86c7399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=A2=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sun, 16 Nov 2025 13:04:26 +0300 Subject: [PATCH 1/6] Added pyproject.toml, installed ruff --- pyproject.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3a7b8de --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.ruff.lint] + extend-select = [ + "F", # Правила Pyflakes + "W", # Предупреждения PyCodeStyle + "E", # Ошибки PyCodeStyle + "I", # Правильно сортировать импорты + "N", # Нейминг + "UP", # Предупреждать, если что-то можно изменить из-за новых версий Python + "C4", # Ловить неправильное использование comprehensions, dict, list и т.д. + "FA", # Применять from __future__ import annotations + "ISC", # Хорошее использование конкатенации строк + "ICN", # Использовать общие соглашения об импорте + "RET", # Хорошие практики возврата + "SIM", # Общие правила упрощения + ] From 90647b2b6f840b1c0cfb98c265ca60c2a635b225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=A2=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sun, 16 Nov 2025 13:14:58 +0300 Subject: [PATCH 2/6] Added ruff.yml for automaticly checking files with ruff --- .github/workflows/ruff.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/ruff.yml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..f963a59 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,11 @@ +name: Ruff + +on: + push: + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/ruff-action@v3 From 49483080a6c496e416056068f9325ef5a9e0c48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=A2=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sun, 16 Nov 2025 13:54:09 +0300 Subject: [PATCH 3/6] Updated ruff.yml, because we need to check only new files --- .github/workflows/ruff.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index f963a59..3a03383 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -8,4 +8,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: astral-sh/ruff-action@v3 + with: + fetch-depth: 0 + + - name: Get changed Python files + id: changed-files + run: | + CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '\.py$' | tr '\n' ' ' || true) + echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT + echo "Changed Python files: $CHANGED_FILES" + + - name: Run Ruff on changed files + if: steps.changed-files.outputs.changed_files != '' + uses: astral-sh/ruff-action@v3 + with: + args: "check --output-format=github ${{ steps.changed-files.outputs.changed_files }}" + + - name: No Python files changed + if: steps.changed-files.outputs.changed_files == '' + run: echo "No Python files to check" From dfc8e34bd072b65565edbd9902d1d9c6275a9c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=A2=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sun, 16 Nov 2025 21:05:27 +0300 Subject: [PATCH 4/6] Updated implementation of the extended Euclidian algorithm --- src/SecondHomeworks/Extended_Euclid.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/SecondHomeworks/Extended_Euclid.py b/src/SecondHomeworks/Extended_Euclid.py index ae34594..72b195d 100644 --- a/src/SecondHomeworks/Extended_Euclid.py +++ b/src/SecondHomeworks/Extended_Euclid.py @@ -1,16 +1,18 @@ def extended_gcd(a, b): remainder0, remainder1 = a, b - factorA0, factorA1 = 1, 0 - factorB0, factorB1 = 0, 1 + factor_a0, factor_a1 = 1, 0 + factor_b0, factor_b1 = 0, 1 while remainder1 != 0: quotient = remainder0 // remainder1 remainder0, remainder1 = remainder1, remainder0 - quotient * remainder1 - factorA0, factorA1 = factorA1, factorA0 - quotient * factorA1 - factorB0, factorB1 = factorB1, factorB0 - quotient * factorB1 + factor_a0, factor_a1 = factor_a1, factor_a0 - quotient * factor_a1 + factor_b0, factor_b1 = factor_b1, factor_b0 - quotient * factor_b1 - return remainder0, factorA0, factorB0 -A, B = int(input()), int(input()) -gcd, factorA, factorB = extended_gcd(A, B) + return remainder0, factor_a0, factor_b0 + + +a, b = int(input()), int(input()) +gcd, factor_a, factor_b = extended_gcd(a, b) print(f"GCD = {gcd}") -print(f"({factorA}) * {A} + ({factorB}) * {B} = {gcd}") \ No newline at end of file +print(f"({factor_a}) * {a} + ({factor_b}) * {b} = {gcd}") From fcaf0d72f00e1da709c6ce60a90be2f9d13f7af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=A2=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sun, 16 Nov 2025 21:55:50 +0300 Subject: [PATCH 5/6] Added version of ruff in .github/workflows/ruff.yml --- .github/workflows/ruff.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 3a03383..8f69dff 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -22,6 +22,7 @@ jobs: if: steps.changed-files.outputs.changed_files != '' uses: astral-sh/ruff-action@v3 with: + version: "0.4.4" args: "check --output-format=github ${{ steps.changed-files.outputs.changed_files }}" - name: No Python files changed From bc0b6b14b1ff80ee65598e9d3fb88f1eef605c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=A2=D0=BE=D1=80=D0=B3?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= Date: Sun, 16 Nov 2025 22:21:25 +0300 Subject: [PATCH 6/6] Added target-version of python in pyproject.toml --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3a7b8de..d268a5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ +[tool.ruff] +target-version = "py312" + [tool.ruff.lint] extend-select = [ "F", # Правила Pyflakes