From 9078421f8da8ed820ec305aa09f417846a0c84e4 Mon Sep 17 00:00:00 2001 From: ada1ra Date: Wed, 8 Oct 2025 12:37:25 +0300 Subject: [PATCH 1/6] Add config file for ruff --- ruff.toml | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 ruff.toml diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..b477208 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,78 @@ +# ruff.toml +target-version = "py311" +line-length = 100 + +# включить все основные правила +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # Pyflakes + "I", # isort + "N", # pep8-naming + "UP", # pyupgrade + "YTT", # flake8-2020 + "S", # flake8-bandit + "A", # flake8-builtins + "COM", # flake8-commas + "C4", # flake8-comprehensions + "DTZ", # flake8-datetimez + "T10", # flake8-debugger + "EM", # flake8-errmsg + "EXE", # flake8-executable + "ISC", # flake8-implicit-str-concat + "ICN", # flake8-import-conventions + "G", # flake8-logging-format + "INP", # flake8-no-pep420 + "PIE", # flake8-pie + "T20", # flake8-print + "PYI", # flake8-pyi + "PT", # flake8-pytest-style + "Q", # flake8-quotes + "RSE", # flake8-raise + "RET", # flake8-return + "SLF", # flake8-self + "SIM", # flake8-simplify + "TID", # flake8-tidy-imports + "TCH", # flake8-type-checking + "INT", # flake8-gettext + "ARG", # flake8-unused-arguments + "FBT", # flake8-boolean-trap + "B", # flake8-bugbear + "AIR", # flake8-airflow + "PERF", # flake8-perflint +] + +# игнорировать правила +ignore = [ + "E501", # line too long - handled by formatter + "S101", # assert used - ok in tests + "T201", # print found - sometimes needed + "COM812", # trailing comma missing - not always required +] + +# настройки для конкретных файлов +[per-file-ignores] +"__init__.py" = ["F401"] # Unused imports allowed in __init__.py +"tests/**" = ["S101", "SLF001"] # Allow assert and self in tests +"**/migrations/**" = ["ALL"] # Ignore all in migrations + +# настройки форматтера +[format] +indent-style = "space" +quote-style = "double" +skip-magic-trailing-comma = false +line-ending = "auto" + +# настройки для конкретных правил +[flake8-quotes] +docstring-quotes = "double" +inline-quotes = "double" + +[flake8-tidy-imports] +ban-relative-imports = "all" + +[isort] +known-first-party = ["myapp"] +lines-after-imports = 2 +combine-as-imports = true +split-on-trailing-comma = true From d6c7214dfdf11b79548d1b6e3fcb8a3af6574597 Mon Sep 17 00:00:00 2001 From: Ada Date: Wed, 8 Oct 2025 13:56:46 +0300 Subject: [PATCH 2/6] Rename ruff.toml to pyproject.toml --- ruff.toml => pyproject.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ruff.toml => pyproject.toml (100%) diff --git a/ruff.toml b/pyproject.toml similarity index 100% rename from ruff.toml rename to pyproject.toml From 364fd5d6d800cdd341d02e7dc394564347bd07d4 Mon Sep 17 00:00:00 2001 From: Ada Date: Wed, 3 Dec 2025 23:37:47 +0300 Subject: [PATCH 3/6] Create new ruff.yml --- .github/workflows/ruff.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 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..8722949 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,36 @@ +name: Ruff Code Quality Check + +on: [ push, pull_request ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ruff: + name: Ruff Check + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Ruff + run: | + pip install ruff + + - name: Run Ruff check + run: | + ruff check . --output-format=github + + - name: Check code formatting + run: | + ruff format --check . --diff From 04ae601e9a0e6deca52dd821704dc6f1ab7445a9 Mon Sep 17 00:00:00 2001 From: Ada Date: Wed, 3 Dec 2025 23:44:09 +0300 Subject: [PATCH 4/6] Fix format for ruff in hw_2_3_euclid_algorithm.py --- src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py b/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py index f6809cb..f2a4fc9 100644 --- a/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py +++ b/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py @@ -10,11 +10,11 @@ def extended_gcd(a, b): return [gcd, x, y] -a = int(input('Введите первое число: ')) -b = int(input('Введите второе число: ')) +a = int(input("Введите первое число: ")) +b = int(input("Введите второе число: ")) gcd, x, y = extended_gcd(a, b) -print(f'НОД({a}, {b}) = {gcd}') -print(f'Коэффициенты: x = {x}, y = {y}') -print(f'Проверка: ({a})*({x}) + ({b})*({y}) = {a * x + b * y}') +print(f"НОД({a}, {b}) = {gcd}") +print(f"Коэффициенты: x = {x}, y = {y}") +print(f"Проверка: ({a})*({x}) + ({b})*({y}) = {a * x + b * y}") From 6178e470ad224a3a7d9ae442b8b9cb112443c384 Mon Sep 17 00:00:00 2001 From: ada1ra Date: Wed, 3 Dec 2025 23:54:51 +0300 Subject: [PATCH 5/6] Fix empty line --- src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py b/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py index f2a4fc9..08d867a 100644 --- a/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py +++ b/src/hw_2_3_euclid_algorithm/hw_2_3_euclid_algorithm.py @@ -17,4 +17,3 @@ def extended_gcd(a, b): print(f"НОД({a}, {b}) = {gcd}") print(f"Коэффициенты: x = {x}, y = {y}") print(f"Проверка: ({a})*({x}) + ({b})*({y}) = {a * x + b * y}") - From 5fb3d0225bf10e40026cc58208d490bd64c9c03a Mon Sep 17 00:00:00 2001 From: ada1ra Date: Wed, 3 Dec 2025 23:58:52 +0300 Subject: [PATCH 6/6] Fix format for ruff in hw_3-2_sort.py --- src/hw_3-2_sort/hw_3-2_sort.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hw_3-2_sort/hw_3-2_sort.py b/src/hw_3-2_sort/hw_3-2_sort.py index d27e05a..5a3a3d8 100644 --- a/src/hw_3-2_sort/hw_3-2_sort.py +++ b/src/hw_3-2_sort/hw_3-2_sort.py @@ -1,5 +1,6 @@ numbers = [1, 2, 3, 9, 3, 8, 478, 7] + def bubble_sort(nums): # значение для запуска цикла swap = True @@ -14,6 +15,6 @@ def bubble_sort(nums): # перезапускаем цикл, для ещё одной проверки swap = True + bubble_sort(numbers) print(numbers) -