Skip to content

Commit

Permalink
linting and cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaminyou committed Jan 19, 2024
1 parent ffe23a1 commit e7f4235
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: flake8 Lint

on: [push, pull_request]

jobs:
flake8-lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: flake8 Lint
uses: py-actions/flake8@v2
26 changes: 20 additions & 6 deletions backend/routers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def change_subordinate_password():

user_account = request.form["account"]
new_password = request.form["password"]
if SubordinateModel.find_by_account_and_subordinate(account=account, subordinate=user_account) is None:
if SubordinateModel.find_by_account_and_subordinate(
account=account,
subordinate=user_account,
) is None:
return {'msg': 'User does not exist'}, HTTPStatus.FORBIDDEN

if UserModel.find_by_account(account=user_account) is None:
Expand Down Expand Up @@ -152,7 +155,10 @@ def manager_upload_gait_csv():
request_form = request.form.to_dict()
target_account = request_form['account'] # should be subordinate
request_form.pop('account', None)
if SubordinateModel.find_by_account_and_subordinate(account=account, subordinate=target_account) is None:
if SubordinateModel.find_by_account_and_subordinate(
account=account,
subordinate=target_account,
) is None:
return {'msg': 'User does not exist'}, HTTPStatus.FORBIDDEN

form_data = request_schema.load(request_form)
Expand Down Expand Up @@ -213,7 +219,10 @@ def manager_request_results():
return {'msg': 'User does not exist'}, HTTPStatus.FORBIDDEN

target_account = request.form['account']
if SubordinateModel.find_by_account_and_subordinate(account=account, subordinate=target_account) is None:
if SubordinateModel.find_by_account_and_subordinate(
account=account,
subordinate=target_account,
) is None:
return {'msg': 'User does not exist'}, HTTPStatus.FORBIDDEN

request_objects = RequestModel.find_by_account_and_sort_by_exp_date(account=target_account)
Expand Down Expand Up @@ -326,7 +335,7 @@ def manager_request_report_download():
stage = profile_object.__dict__['stage']
dominantSide = profile_object.__dict__['dominantSide']
lded = profile_object.__dict__['lded']
ss = f'{target_account},{name},{gender},{birthday},{diagnose},{stage},{dominantSide},{lded},'
ss = f'{target_account},{name},{gender},{birthday},{diagnose},{stage},{dominantSide},{lded},' # noqa

orders = [
'stride length',
Expand All @@ -340,7 +349,9 @@ def manager_request_report_download():
request_objects = RequestModel.find_by_account(account=target_account)
for request_object in request_objects:
sss = ss + f'{request_object.__dict__["date"].strftime("%Y-%m-%d")}'
result_objects = ResultModel.find_by_requestUUID(requestUUID=request_object.__dict__["submitUUID"])
result_objects = ResultModel.find_by_requestUUID(
requestUUID=request_object.__dict__["submitUUID"],
)
collections = {
'stride length': 0,
'stride width': 0,
Expand Down Expand Up @@ -400,7 +411,10 @@ def manager_get_user_profile():
return {'msg': 'User does not exist'}, HTTPStatus.FORBIDDEN

target_account = request.form['account']
if SubordinateModel.find_by_account_and_subordinate(account=account, subordinate=target_account) is None:
if SubordinateModel.find_by_account_and_subordinate(
account=account,
subordinate=target_account,
) is None:
return {'msg': 'User does not exist'}, HTTPStatus.FORBIDDEN

profile_object = ProfileModel.find_latest_by_account(account=target_account)
Expand Down
5 changes: 4 additions & 1 deletion backend/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ omit = *tests/*, **/_saferepr.py
branch = True

[flake8]
max-line-length = 119
max-line-length = 100
max-complexity = 10
ignore =
# Do not assign a lambda expression, use a def (https://www.flake8rules.com/rules/E731.html)
E731,
Expand All @@ -38,6 +39,7 @@ ignore =
D,DAR,RST
# Found commented out code, not ready...
E800
C901

exclude =
.git,
Expand All @@ -49,6 +51,7 @@ exclude =
build/
# sphinx docs
docs/
algorithms/gait_basic

per-file-ignores =
# allow non-optimized or insecure code in tests
Expand Down
1 change: 1 addition & 0 deletions backend/wsgi.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# flake8: noqa
from app import app
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 100
extend-ignore = C901
exclude = backend/algorithms/gait_basic
max-complexity = 10

0 comments on commit e7f4235

Please sign in to comment.