Skip to content

Commit d9d13c2

Browse files
authored
Merge pull request #2 from pythonkr/add-mypy
CI: mypy를 포함한 몇몇 linter들을 추가합니다
2 parents fd892ea + 24ff3b3 commit d9d13c2

File tree

6 files changed

+126
-5
lines changed

6 files changed

+126
-5
lines changed

.pre-commit-config.yaml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
default_language_version:
4+
python: python3.11
5+
default_stages: [pre-commit, pre-push]
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.5.0
9+
hooks:
10+
- id: check-json
11+
- id: check-toml
12+
- id: check-xml
13+
- id: check-yaml
14+
- id: check-added-large-files
15+
- id: detect-aws-credentials
16+
- id: detect-private-key
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
- id: pretty-format-json
20+
- id: trailing-whitespace
21+
exclude_types:
22+
- javascript
23+
- markdown
24+
- repo: https://github.com/PyCQA/flake8
25+
rev: 7.0.0
26+
hooks:
27+
- id: flake8
28+
additional_dependencies:
29+
- flake8-bugbear
30+
- flake8-noqa
31+
args:
32+
- --max-line-length=120
33+
- --max-complexity=18
34+
- repo: https://github.com/psf/black
35+
rev: 24.3.0
36+
hooks:
37+
- id: black
38+
language_version: python3.11
39+
args:
40+
- --line-length=120
41+
- repo: https://github.com/PyCQA/bandit
42+
rev: '1.7.8'
43+
hooks:
44+
- id: bandit
45+
- repo: https://github.com/PyCQA/isort
46+
rev: '5.13.2'
47+
hooks:
48+
- id: isort
49+
- repo: https://github.com/pre-commit/mirrors-mypy
50+
rev: 'v1.9.0'
51+
hooks:
52+
- id: mypy
53+
args:
54+
- --no-strict-optional
55+
- --ignore-missing-imports
56+
- --check-untyped-defs
57+
- --disallow-untyped-defs
58+
- --disallow-incomplete-defs
59+
- --disallow-untyped-calls
60+
- repo: https://github.com/dosisod/refurb
61+
rev: v2.0.0
62+
hooks:
63+
- id: refurb

Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Setup development environment
2+
setup:
3+
poetry install
4+
5+
# Devtools
6+
hooks-install: setup
7+
poetry run pre-commit install
8+
9+
hooks-upgrade:
10+
poetry run pre-commit autoupdate
11+
12+
hooks-lint:
13+
poetry run pre-commit run --all-files
14+
15+
lint: hooks-lint # alias
16+
17+
hooks-mypy:
18+
poetry run pre-commit run mypy --all-files
19+
20+
mypy: hooks-mypy # alias

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# PyCon Korea API Server (2024 ~)
2+
3+
## 1. 로컬 개발 환경 설정
4+
본 프로젝트는 Python3.11 (또는 이후 버전)과 Poetry를 사용합니다.
5+
- Poetry 설치는 [여기](https://python-poetry.org/docs/)에서 확인해주세요.
6+
7+
### 1.1. 프로젝트 설치
8+
```bash
9+
poetry install
10+
```
11+
12+
### 1.2. pre-commit hook 설정
13+
본 프로젝트에서는 코딩 컨벤션을 준수하기 위해 [pre-commit](https://pre-commit.com/)을 사용합니다.
14+
pre-commit을 설치하려면 다음을 참고해주세요.
15+
16+
#### 1.2.1. Linux / macOS
17+
```bash
18+
# 설치
19+
make hooks-install
20+
21+
# 프로젝트 전체 코드 lint 검사 & format
22+
make lint
23+
24+
# 프로젝트 전체 코드에 대해 mypy 타입 검사
25+
make mypy
26+
```
27+
28+
#### 1.2.2. Windows
29+
```bash
30+
# 설치
31+
poetry run pre-commit install
32+
33+
# 프로젝트 전체 코드 lint 검사 & format
34+
poetry run pre-commit run --all-files
35+
36+
# 프로젝트 전체 코드에 대해 mypy 타입 검사
37+
poetry run pre-commit run mypy --all-files
38+
```

manage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55

66

7-
def main():
7+
def main() -> None:
88
"""Run administrative tasks."""
99
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pyconkr.settings")
1010
try:

pyconkr/settings.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = "django-insecure-kjtg@&v106jt2wz9tlci@b!3uqrig7eud^3zk53&!me@gw_(q@"
23+
SECRET_KEY = "django-insecure-kjtg@&v106jt2wz9tlci@b!3uqrig7eud^3zk53&!me@gw_(q@" # nosec: B105
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
2727

28-
ALLOWED_HOSTS = []
28+
ALLOWED_HOSTS: list[str] = []
2929

3030

3131
# Application definition
@@ -54,8 +54,7 @@
5454
TEMPLATES = [
5555
{
5656
"BACKEND": "django.template.backends.django.DjangoTemplates",
57-
"DIRS": [BASE_DIR / 'templates']
58-
,
57+
"DIRS": [BASE_DIR / "templates"],
5958
"APP_DIRS": True,
6059
"OPTIONS": {
6160
"context_processors": [

pyconkr/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
1. Import the include() function: from django.urls import include, path
1515
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1616
"""
17+
1718
from django.contrib import admin
1819
from django.urls import path
1920

0 commit comments

Comments
 (0)