Skip to content
Open
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
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
name: Run black formatter
language_version: python3


- repo: local
hooks:

- id: mypy
name: Run mypy
entry: mypy application --ignore-missing-imports --follow-imports=skip
language: system
pass_filenames: false


- id: flask-tests
name: Run Flask tests
entry: make test
language: system
pass_filenames: false


- id: coverage-check
name: Coverage >= 70%
entry: make cover
language: system
pass_filenames: false
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test:
flask routes && flask test

cover:
. ./venv/bin/activate && FLASK_APP=cre.py FLASK_CONFIG=testing flask test --cover
. ./venv/bin/activate && FLASK_APP=cre.py FLASK_CONFIG=testing FLASK_COVERAGE=1 flask test --cover

install-deps-python:
[ -d "./venv" ] && . ./venv/bin/activate &&\
Expand Down
6 changes: 5 additions & 1 deletion application/cmd/cre_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time
import argparse
import json

# mypy: disable-error-code="arg-type,return-value,union-attr,assignment,attr-defined"
import logging
import os
import shutil
Expand Down Expand Up @@ -192,7 +194,9 @@ def parse_file(
else (
defs.Code
if doctype == defs.Credoctypes.Code.value
else defs.Tool if doctype == defs.Credoctypes.Tool.value else None
else defs.Tool
if doctype == defs.Credoctypes.Tool.value
else None
)
)
document = from_dict(
Expand Down
2 changes: 2 additions & 0 deletions application/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Config:
GAP_ANALYSIS_OPTIMIZED = (
os.environ.get("GAP_ANALYSIS_OPTIMIZED", "False").lower() == "true"
)
ENABLE_MYOPENCRE = ENABLE_MYOPENCRE


class DevelopmentConfig(Config):
Expand All @@ -30,6 +31,7 @@ class TestingConfig(Config):
CACHE_TYPE = "SimpleCache"
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get("TEST_DATABASE_URL") or "sqlite://"
ENABLE_MYOPENCRE = True


class ProductionConfig(Config):
Expand Down
Loading