Skip to content

Add pre-commit hooks, removed pre-push script #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""
Copy content from env template (autogenerated passwords etc)
Copy content from env template (autogenerated passwords etc)
to .env which is gitignored, then remove template env file as it is redundant.
"""
from pathlib import Path

PROJECT_NAME = "{{ cookiecutter.project_name }}"


def create_env_file_and_remove_env_template():
env_template_file = Path(".env.template")
env_file = Path(".env")
Expand Down
13 changes: 13 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 88
select = C,E,F,W,B,B9
ignore = E203, E501, W503
exclude =
__init__.py,
.venv,
venv,
__pycache__,
.github,
.vscode,
[isort]
profile = black
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
max-line-length = 88
select = C,E,F,W,B,B9
ignore = E203, E501, W503
exclude =
exclude =
__init__.py,
.venv,
venv,
Expand Down
56 changes: 56 additions & 0 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: trailing-whitespace

- repo: https://github.com/myint/autoflake
rev: "v2.0.1"
hooks:
- id: autoflake
args:
[
"--recursive",
"--in-place",
"--remove-unused-variables",
"--remove-all-unused-imports",
"--ignore-init-module-imports",
]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
[
"--py3-plus",
"--py36-plus",
"--py37-plus",
"--py38-plus",
"--py39-plus",
"--py310-plus",
"--py311-plus",
]
files: ".*"

- repo: https://github.com/psf/black
rev: "23.1.0"
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: "5.12.0"
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: "6.0.0"
hooks:
- id: flake8

- repo: https://github.com/python-poetry/poetry
rev: "1.3.0"
hooks:
- id: poetry-export
args: ["-o", "requirements.txt", "--without-hashes"]
11 changes: 5 additions & 6 deletions {{cookiecutter.project_name}}/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
from logging.config import fileConfig

from sqlalchemy import engine_from_config
from sqlalchemy import pool
from sqlalchemy import engine_from_config, pool
from sqlalchemy.ext.asyncio import AsyncEngine
import asyncio
from app.core import config as app_config
from alembic import context

from alembic import context
from app.core import config as app_config

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

target_metadata = Base.metadata

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""init_user_model

Revision ID: 07c71f4389b6
Revises:
Revises:
Create Date: 2023-02-04 23:40:00.426237

"""
from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "07c71f4389b6"
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/app/api/deps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from typing import AsyncGenerator
from collections.abc import AsyncGenerator

import jwt
from fastapi import Depends, HTTPException, status
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/app/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from typing import AsyncGenerator
from collections.abc import AsyncGenerator

import pytest
import pytest_asyncio
Expand Down
16 changes: 0 additions & 16 deletions {{cookiecutter.project_name}}/pre-push.sh

This file was deleted.

59 changes: 0 additions & 59 deletions {{cookiecutter.project_name}}/requirements-dev.txt

This file was deleted.