From 3315ab175aad5afb81d79436e4e28a46faefc08d Mon Sep 17 00:00:00 2001 From: Sepehr Akbarzadeh Date: Thu, 5 Dec 2024 12:48:39 +0330 Subject: [PATCH] style(pre-commit): obey rules --- .github/workflows/ci.yml | 4 +-- .pre-commit-config-ci.yaml | 4 +-- iranian_cities/mixins/dynamic_permission.py | 12 +++++-- pyproject.toml | 40 ++++++++++----------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de1a0b4..9ad8ab0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: env: DJANGO_SETTINGS_MODULE: tests.testapp.settings.settings PYTHONPATH: ${{ github.workspace }} - + strategy: matrix: python-version: @@ -19,7 +19,7 @@ jobs: - '3.10' - '3.11' - '3.12' - + steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config-ci.yaml b/.pre-commit-config-ci.yaml index 1401d0d..e8667b3 100644 --- a/.pre-commit-config-ci.yaml +++ b/.pre-commit-config-ci.yaml @@ -39,7 +39,7 @@ repos: - id: ruff args: ["--config=pyproject.toml"] exclude: (migrations/|tests/|docs/|static/|media/|apps.py).* - + - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: @@ -98,4 +98,4 @@ repos: types: [ python ] stages: [ commit ] pass_filenames: false - always_run: true \ No newline at end of file + always_run: true diff --git a/iranian_cities/mixins/dynamic_permission.py b/iranian_cities/mixins/dynamic_permission.py index f9bc69c..e2092f8 100644 --- a/iranian_cities/mixins/dynamic_permission.py +++ b/iranian_cities/mixins/dynamic_permission.py @@ -3,13 +3,19 @@ class IranianCitiesAdminReadOnlyEnabled: def has_add_permission(self, request): - return not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_ADD_READONLY_ENABLED + return ( + not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_ADD_READONLY_ENABLED + ) def has_delete_permission(self, request, obj=None): - return not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED + return ( + not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED + ) def has_change_permission(self, request, obj=None): - return not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED + return ( + not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED + ) class DynamicInlineAdmin: diff --git a/pyproject.toml b/pyproject.toml index c20e4dd..3eae91e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,30 +41,11 @@ pylint = "^3.2.6" pylint-django = "^2.5.5" docformatter = "^1.7.5" commitizen = "^3.28.0" -bandit = {extras = ["toml"], version = "^1.7.9"} +bandit = { extras = [ "toml" ], version = "^1.7.9" } poetry-plugin-export = "^1.8.0" django-debug-toolbar = "^4.4.6" django-migration-linter = "^5.1.0" -[tool.bandit] -targets = ["./iranian_cities"] -exclude_dirs = [ - "tests", - "migrations", -] -severity = "medium" -confidence = "medium" -max_lines = 500 -progress = true -reports = true -output_format = "screen" -output_file = "bandit_report.txt" -include = ["B101", "B102"] -exclude_tests = ["B301", "B302"] - -[tool.bandit.plugins] -B104 = { check_typed_list = true } - [tool.black] line-length = 88 exclude = ''' @@ -249,6 +230,25 @@ exclude = ''' ^kernel/ ''' +[tool.bandit] +targets = [ "./iranian_cities" ] +exclude_dirs = [ + "tests", + "migrations", +] +severity = "medium" +confidence = "medium" +max_lines = 500 +progress = true +reports = true +output_format = "screen" +output_file = "bandit_report.txt" +include = [ "B101", "B102" ] +exclude_tests = [ "B301", "B302" ] + +[tool.bandit.plugins] +B104 = { check_typed_list = true } + [tool.commitizen] name = "cz_conventional_commits" version = "0.1.0"