Skip to content

Commit

Permalink
refactoring, pre-commit added
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Shershen authored and Eugene Shershen committed Oct 22, 2021
1 parent 5b16d47 commit 3e84c56
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
exclude = .venv
max-line-length = 100
extend-ignore = E203
extend-ignore = E203
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
push:
branches:
- main

jobs:
test:
name: test
Expand Down Expand Up @@ -35,35 +35,35 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
# test all the builds apart from linux_3.8...
- name: Test with pytest
if: matrix.build != 'linux_3.8'
run: pytest

# only do the test coverage for linux_3.8
- name: Produce coverage report
if: matrix.build == 'linux_3.8'
run: pytest --cov=fastapi_async_sqlalchemy --cov-report=xml

- name: Upload coverage report
if: matrix.build == 'linux_3.8'
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml

lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
Expand All @@ -86,12 +86,12 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install dependencies
# isort needs all of the packages to be installed so it can
# isort needs all of the packages to be installed so it can
# tell which are third party and which are first party
run: pip install -r requirements.txt

- name: Check formatting of imports
run: isort --check-only --diff --verbose

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ __pycache__/
htmlcov/
test.py
*.egg-info
coverage.xml
coverage.xml
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
exclude: (alembic|build|dist|docker|esign|kubernetes|migrations)

default_language_version:
python: python3.7

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.28.0
hooks:
- id: pyupgrade
args:
- --py37-plus
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --expand-star-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
args:
- --max-line-length=100
- --ignore=E203, E501, W503
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
hooks:
- id: mypy
additional_dependencies:
- pydantic
- types-ujson
2 changes: 1 addition & 1 deletion .pyup.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# autogenerated pyup.io config file
# autogenerated pyup.io config file
# see https://pyup.io/docs/configuration/ for all available options

schedule: ''
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

### Description

FastAPI-Async-SQLAlchemy provides middleware for FastAPI and SQLAlchemy using async AsyncSession and async engine.
FastAPI-Async-SQLAlchemy provides middleware for FastAPI and SQLAlchemy using async AsyncSession and async engine.
Based on FastAPI-SQLAlchemy

### Install
Expand All @@ -34,7 +34,7 @@ from sqlalchemy import table

app = FastAPI()
app.add_middleware(
SQLAlchemyMiddleware,
SQLAlchemyMiddleware,
db_url="postgresql+asyncpg://user:[email protected]:5432/primary_db"
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 100
line_length = 100
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup

with open(Path("fastapi_async_sqlalchemy") / "__init__.py", encoding="utf-8") as fh:
version = re.search(r'__version__ = "(.*?)"', fh.read(), re.M).group(1)
version = re.search(r'__version__ = "(.*?)"', fh.read(), re.M).group(1) # type: ignore

with open("README.md", encoding="utf-8") as fh:
long_description = fh.read()
Expand Down

0 comments on commit 3e84c56

Please sign in to comment.