Skip to content

Commit b758e76

Browse files
committed
moved python files to /backend (#243)
1 parent 5246fd9 commit b758e76

24 files changed

+18
-19
lines changed

.github/workflows/lint-python.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
npm install -g pyright
3535
- run: mv configs.template.py configs.py
3636
- name: Analysing the code with ${{ job.name }}
37-
run: pyright --warnings
37+
run: pyright --warnings backend
3838
Pylint:
3939
runs-on: ubuntu-latest
4040
steps:
@@ -51,7 +51,7 @@ jobs:
5151
pip install -r "scripts/requirements.txt"
5252
- run: mv configs.template.py configs.py
5353
- name: Analysing the code with ${{ job.name }}
54-
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py*')
54+
run: pylint --reports=y --output-format=colorized $(git ls-files 'backend/*.py*')
5555
Flake8:
5656
runs-on: ubuntu-latest
5757
steps:
@@ -68,7 +68,7 @@ jobs:
6868
pip install -r "scripts/requirements.txt"
6969
- run: mv configs.template.py configs.py
7070
- name: Analysing the code with ${{ job.name }}
71-
run: flake8
71+
run: flake8 backend
7272
Bandit:
7373
runs-on: ubuntu-latest
7474
steps:
@@ -85,4 +85,4 @@ jobs:
8585
pip install -r "scripts/requirements.txt"
8686
- run: mv configs.template.py configs.py
8787
- name: Analysing the code with ${{ job.name }}
88-
run: bandit -n 1 --severity-level medium --recursive .
88+
run: bandit -n 1 --severity-level medium --recursive backend

api/api_wrappers.py renamed to backend/api/api_wrappers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import json
2+
13
from datetime import datetime, timedelta
24
from functools import wraps
35
from flask import current_app, jsonify, request
4-
import json
56
import jwt
67

78
from models.core_models import Player
File renamed without changes.
File renamed without changes.
File renamed without changes.

api/tournament_scheduler_api.py renamed to backend/api/tournament_scheduler_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ def __validate_create_schedule(data: Optional[JSONObjectType]):
304304
except KeyError:
305305
error_message += "active has to be defined"
306306
try:
307-
deadlineData = data["deadline"]
308-
deadline = None if deadlineData is None else str(deadlineData)
307+
deadline_data = data["deadline"]
308+
deadline = None if deadline_data is None else str(deadline_data)
309309
except KeyError:
310310
error_message += "deadline has to be defined"
311311
try:
File renamed without changes.
File renamed without changes.

models/core_models.py renamed to backend/models/core_models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def get(user_id: str):
8787

8888
@staticmethod
8989
def get_all():
90-
sql = text("SELECT user_id, name, country_code, score, last_update, CONVERT(rank, SIGNED INT) rank FROM ( " +
91-
" SELECT *, "
90+
sql = text("SELECT user_id, name, country_code, score, last_update, CONVERT(rank, SIGNED INT) rank FROM ( "
91+
+ " SELECT *, "
9292
+ " IF(score = @_last_score, @cur_rank := @cur_rank, @cur_rank := @_sequence) AS rank, "
9393
+ " @_sequence := @_sequence + 1, "
9494
+ " @_last_score := score "
File renamed without changes.

services/user_updater.py renamed to backend/services/user_updater.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from services.user_updater_helpers import BasicJSONType, extract_valid_personal_bests, get_probability_terms, \
1515
get_subcategory_variables, keep_runs_before_soft_cutoff, MIN_LEADERBOARD_SIZE, update_runner_in_database, \
1616
extract_top_runs_and_score, extract_sorted_valid_runs_from_leaderboard
17-
from services.utils import clear_cache_for_user_async, get_file, get_paginated_response, MAXIMUM_RESULTS_PER_PAGE, \
18-
SpeedrunComError, start_and_wait_for_threads, UserUpdaterError
17+
from services.utils import clear_cache_for_user_async, get_file, get_paginated_response, \
18+
MAXIMUM_RESULTS_PER_PAGE, SpeedrunComError, start_and_wait_for_threads, UserUpdaterError
1919
import configs
2020

2121
TIME_BONUS_DIVISOR = 3600 * 12 # 12h (1/2 day) for +100%

services/utils.py renamed to backend/services/utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from types import TracebackType
22
from typing import Any, Literal, Optional, Union
33

4+
from collections import Counter
45
from concurrent.futures import ThreadPoolExecutor
56
from contextlib import nullcontext
67
from datetime import timedelta
@@ -359,9 +360,6 @@ def start_and_wait_for_threads(fn, items: list):
359360
) from exception
360361

361362

362-
from collections import Counter
363-
364-
365363
def get_duplicates(array: list):
366364
counter = Counter(array)
367365
return [key for key in counter if counter[key] > 1]

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ evaluation = "10.0 - error - ((float((warning + convention) * 10 + refactor ) /
4040
[tool.pylint.MASTER]
4141
fail-under = 9.0
4242
# Needed for Pylint to discover our own modules
43-
init-hook = "import os, sys; sys.path.append(os.path.dirname('.'))"
43+
init-hook = "from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.join(os.path.dirname(find_pylintrc()), 'backend'))"
4444
# https://pylint.pycqa.org/en/latest/technical_reference/extensions.html
4545
load-plugins = [
4646
"pylint.extensions.emptystring",

scripts/lint.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Write-Host $Script:MyInvocation.MyCommand.Path
44
$exitCodes = 0
55

66
Write-Host "`nRunning Pyright..."
7-
pyright --warnings
7+
pyright --warnings backend
88
$exitCodes += $LastExitCode
99
if ($LastExitCode -gt 0) {
1010
Write-Host "`Pyright failed ($LastExitCode)" -ForegroundColor Red
@@ -13,7 +13,7 @@ if ($LastExitCode -gt 0) {
1313
}
1414

1515
Write-Host "`nRunning Pylint..."
16-
pylint --score=n --output-format=colorized $(git ls-files '**/*.py')
16+
pylint --score=n --output-format=colorized $(git ls-files 'backend/*.py')
1717
$exitCodes += $LastExitCode
1818
if ($LastExitCode -gt 0) {
1919
Write-Host "`Pylint failed ($LastExitCode)" -ForegroundColor Red
@@ -22,7 +22,7 @@ if ($LastExitCode -gt 0) {
2222
}
2323

2424
Write-Host "`nRunning Flake8..."
25-
flake8
25+
flake8 backend
2626
$exitCodes += $LastExitCode
2727
if ($LastExitCode -gt 0) {
2828
Write-Host "`Flake8 failed ($LastExitCode)" -ForegroundColor Red
@@ -31,7 +31,7 @@ if ($LastExitCode -gt 0) {
3131
}
3232

3333
Write-Host "`nRunning Bandit..."
34-
bandit -f custom --silent --recursive src
34+
bandit -f custom --silent --recursive backend
3535
# $exitCodes += $LastExitCode # Returns 1 on low
3636
if ($LastExitCode -gt 0) {
3737
Write-Host "`Bandit warning ($LastExitCode)" -ForegroundColor Yellow

0 commit comments

Comments
 (0)