Skip to content

Commit 83f60c5

Browse files
authored
Merge pull request #26 from rafsaf/switch-to-pre-commit
Add pre-commit hooks, removed pre-push script
2 parents d1dd328 + 029ce59 commit 83f60c5

File tree

10 files changed

+81
-87
lines changed

10 files changed

+81
-87
lines changed

hooks/post_gen_project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""
2-
Copy content from env template (autogenerated passwords etc)
2+
Copy content from env template (autogenerated passwords etc)
33
to .env which is gitignored, then remove template env file as it is redundant.
44
"""
55
from pathlib import Path
66

77
PROJECT_NAME = "{{ cookiecutter.project_name }}"
88

9+
910
def create_env_file_and_remove_env_template():
1011
env_template_file = Path(".env.template")
1112
env_file = Path(".env")

setup.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-line-length = 88
3+
select = C,E,F,W,B,B9
4+
ignore = E203, E501, W503
5+
exclude =
6+
__init__.py,
7+
.venv,
8+
venv,
9+
__pycache__,
10+
.github,
11+
.vscode,
12+
[isort]
13+
profile = black

{{cookiecutter.project_name}}/.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
max-line-length = 88
33
select = C,E,F,W,B,B9
44
ignore = E203, E501, W503
5-
exclude =
5+
exclude =
66
__init__.py,
77
.venv,
88
venv,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-yaml
6+
- id: trailing-whitespace
7+
8+
- repo: https://github.com/myint/autoflake
9+
rev: "v2.0.1"
10+
hooks:
11+
- id: autoflake
12+
args:
13+
[
14+
"--recursive",
15+
"--in-place",
16+
"--remove-unused-variables",
17+
"--remove-all-unused-imports",
18+
"--ignore-init-module-imports",
19+
]
20+
21+
- repo: https://github.com/asottile/pyupgrade
22+
rev: v3.3.1
23+
hooks:
24+
- id: pyupgrade
25+
args:
26+
[
27+
"--py3-plus",
28+
"--py36-plus",
29+
"--py37-plus",
30+
"--py38-plus",
31+
"--py39-plus",
32+
"--py310-plus",
33+
"--py311-plus",
34+
]
35+
files: ".*"
36+
37+
- repo: https://github.com/psf/black
38+
rev: "23.1.0"
39+
hooks:
40+
- id: black
41+
42+
- repo: https://github.com/pycqa/isort
43+
rev: "5.12.0"
44+
hooks:
45+
- id: isort
46+
47+
- repo: https://github.com/PyCQA/flake8
48+
rev: "6.0.0"
49+
hooks:
50+
- id: flake8
51+
52+
- repo: https://github.com/python-poetry/poetry
53+
rev: "1.3.0"
54+
hooks:
55+
- id: poetry-export
56+
args: ["-o", "requirements.txt", "--without-hashes"]

{{cookiecutter.project_name}}/alembic/env.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import asyncio
12
from logging.config import fileConfig
23

3-
from sqlalchemy import engine_from_config
4-
from sqlalchemy import pool
4+
from sqlalchemy import engine_from_config, pool
55
from sqlalchemy.ext.asyncio import AsyncEngine
6-
import asyncio
7-
from app.core import config as app_config
8-
from alembic import context
96

7+
from alembic import context
8+
from app.core import config as app_config
109

1110
# this is the Alembic Config object, which provides
1211
# access to the values within the .ini file in use.
@@ -20,7 +19,7 @@
2019
# for 'autogenerate' support
2120
# from myapp import mymodel
2221
# target_metadata = mymodel.Base.metadata
23-
from app.models import Base
22+
from app.models import Base # noqa
2423

2524
target_metadata = Base.metadata
2625

{{cookiecutter.project_name}}/alembic/versions/2023020440_init_user_model_07c71f4389b6.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""init_user_model
22
33
Revision ID: 07c71f4389b6
4-
Revises:
4+
Revises:
55
Create Date: 2023-02-04 23:40:00.426237
66
77
"""
8-
from alembic import op
98
import sqlalchemy as sa
109

10+
from alembic import op
1111

1212
# revision identifiers, used by Alembic.
1313
revision = "07c71f4389b6"

{{cookiecutter.project_name}}/app/api/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import time
2-
from typing import AsyncGenerator
2+
from collections.abc import AsyncGenerator
33

44
import jwt
55
from fastapi import Depends, HTTPException, status

{{cookiecutter.project_name}}/app/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
from typing import AsyncGenerator
2+
from collections.abc import AsyncGenerator
33

44
import pytest
55
import pytest_asyncio

{{cookiecutter.project_name}}/pre-push.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

{{cookiecutter.project_name}}/requirements-dev.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)