Skip to content

Commit

Permalink
django 5.0 업데이트
Browse files Browse the repository at this point in the history
lint & formatting ruff 기반으로 변경
  • Loading branch information
enoch2110 committed Dec 27, 2023
1 parent cf68b0a commit 8f1791b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- uses: chartboost/ruff-action@v1
- uses: chartboost/ruff-action@v1
with:
version: 0.0.272
args: format --check
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.272
rev: v0.1.7
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
args: [ --fix ]
- id: ruff-format
4 changes: 1 addition & 3 deletions apps/shared/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def get_cropped_thumbnail(image, width=300, height=300, box=None, crop=True):

def get_cropped_thumbnail_url(image, width=300, height=300, box=None, crop=True):
try:
return get_cropped_thumbnail(
image, width=width, height=height, box=box, crop=crop
).url
return get_cropped_thumbnail(image, width=width, height=height, box=box, crop=crop).url
except Exception:
return ''
7 changes: 4 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{ project_name }}.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'playground.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
'available on your PYTHONPATH environment variable? Did you '
'forget to activate a virtual environment?'
) from exc
execute_from_command_line(sys.argv)

Expand Down
16 changes: 6 additions & 10 deletions project_name/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,18 @@


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {'default': env.db()}

DATABASES['default']['ATOMIC_REQUESTS'] = True


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': (
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
),
},
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
Expand All @@ -100,7 +96,7 @@


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
# https://docs.djangoproject.com/en/5.0/topics/i18n/

LANGUAGE_CODE = 'ko'

Expand All @@ -112,7 +108,7 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = '/static/'

Expand All @@ -126,6 +122,6 @@


# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
19 changes: 9 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[tool.ruff]
select = ['F', 'E', 'W', 'I', 'D', 'N', 'DJ', 'ISC', 'ICN', 'G', 'INP', 'PIE', 'T20', 'Q', 'RSE', 'SIM', 'INT', 'RUF']
ignore = ['D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D106', 'D107', 'DJ008']
select = ['F', 'W', 'E', 'I', 'D', 'N', 'DJ', 'ISC', 'ICN', 'G', 'INP', 'PIE', 'T20', 'Q', 'RSE', 'SIM', 'INT']
ignore = ['W191', 'E111', 'E114', 'E117', 'D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D106', 'D107', 'D206', 'D300', 'Q000', 'Q001', 'Q002', 'Q003', 'COM812', 'COM819', 'DJ008', 'ISC001', 'ISC002']
extend-exclude = ['migrations']
line-length = 120

[tool.ruff.format]
exclude = ['migrations']
quote-style = 'single'
preview = true

[tool.ruff.pydocstyle]
convention = 'google'

[tool.ruff.flake8-quotes]
inline-quotes = 'single'

[tool.black]
target-version = ['py311']
skip-string-normalization = true
preview = true
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==4.2.3
django==5.0
django-cleanup
django-environ
easy-thumbnails
psycopg2-binary
psycopg[binary]

0 comments on commit 8f1791b

Please sign in to comment.