Skip to content

Commit

Permalink
extract code quality GHA to is own job
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwojcik committed Feb 2, 2025
1 parent 6ef1579 commit a93c89a
Show file tree
Hide file tree
Showing 7 changed files with 578 additions and 510 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@ jobs:
- name: Install dependencies
run: |
poetry install --all-extras
poetry install --only code-quality --verbose
echo "Installed packages:"
poetry show
echo "Active environment:"
poetry env info
- name: List pre-commit hooks
run: |
echo "Available pre-commit hooks:"
poetry run pre-commit list-files
poetry run pre-commit list
- name: Run pre-commit with debug
run: |
echo "Running pre-commit hooks with verbose output..."
Expand All @@ -64,9 +58,3 @@ jobs:
git diff
exit 1
fi
- name: Run hooks (if previous step failed)
if: failure()
run: |
echo "Attempting to run make run-hooks directly..."
make run-hooks --debug
20 changes: 11 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: debug-statements
- id: check-added-large-files
Expand All @@ -12,30 +12,32 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/ambv/black
rev: 22.12.0
rev: 25.1.0
hooks:
- id: black
language_version: python3
entry: black
require_serial: true
types: [ python ]

- repo: https://github.com/myint/docformatter
rev: v1.5.1
hooks:
- id: docformatter
# broken?
# - repo: https://github.com/myint/docformatter
# rev: v1.5.1
# hooks:
# - id: docformatter
# language: python

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.236'
rev: 'v0.9.4'
hooks:
- id: ruff
name: ruff
stages: [ commit ]
stages: [ pre-commit ]
types: [ file, python ]
args: ["--fix"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.19.1
hooks:
- id: pyupgrade
args: [ --py38-plus ]
2 changes: 1 addition & 1 deletion djoser/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def has_object_permission(self, request, view, obj):
class CurrentUserOrAdminOrReadOnly(permissions.IsAuthenticated):
def has_object_permission(self, request, view, obj):
user = request.user
if type(obj) == type(user) and obj == user:
if type(obj) is type(user) and obj == user:
return True
return request.method in SAFE_METHODS or user.is_staff
1,043 changes: 560 additions & 483 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ packages = [
]

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
djangorestframework-simplejwt = "^5.0"
social-auth-app-django = "^5.0.0"
djet = { version = "^0.3.0", optional = true }
Expand Down Expand Up @@ -65,6 +65,7 @@ ruff = "^0.0.241"
docformatter = "^1.5.1"
pyupgrade = "^3.3.1"
pre-commit-hooks = "^4.4.0"
pre-commit = "^4.1.0"

[tool.poetry.group.docs.dependencies]
sphinx = "^6.1.3"
Expand Down Expand Up @@ -99,7 +100,7 @@ exclude = '''

[tool.ruff]
select = ["E", "F"]
ignore = []
exclude = ["conf.py", ".venv"]

fixable = ["A", "B", "C", "D", "E", "F"]
unfixable = []
Expand Down
2 changes: 1 addition & 1 deletion testproject/testapp/tests/test_password_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_post_should_send_email_to_custom_user_with_password_reset_link(
AUTH_USER_MODEL="testapp.CustomUser",
DJOSER=dict(settings.DJOSER, **{"PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND": True}),
)
def test_post_should_return_bad_request_with_custom_email_field_if_user_does_not_exist( # NOQA: 501
def test_post_should_return_bad_request_with_custom_email_field_if_user_does_not_exist( # NOQA: E501
self,
):
data = {"custom_email": "[email protected]"}
Expand Down
2 changes: 1 addition & 1 deletion testproject/testapp/tests/test_reset_username.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_post_should_send_email_to_custom_user_with_username_reset_link(
AUTH_USER_MODEL="testapp.CustomUser",
DJOSER=dict(settings.DJOSER, **{"USERNAME_RESET_SHOW_EMAIL_NOT_FOUND": True}),
)
def test_post_should_return_bad_request_with_custom_email_field_if_user_does_not_exist( # NOQA: 501
def test_post_should_return_bad_request_with_custom_email_field_if_user_does_not_exist( # NOQA: E501
self,
):
data = {"custom_email": "[email protected]"}
Expand Down

0 comments on commit a93c89a

Please sign in to comment.