Skip to content
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
55 changes: 6 additions & 49 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Python Linting and Formatting
on: [push]

jobs:
pylint:
name: Pylint
ruff:
name: Ruff (Linting & Formatting)
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -22,52 +22,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r test_requirements.txt
- name: Analysing the code with pylint
- name: Run ruff linter
run: |
pylint $(git ls-files '*.py') --output-format github

black:
name: Black
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
strategy:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r test_requirements.txt
- name: Check code formatting with black
run: |
black --check $(git ls-files '*.py')

isort:
name: isort
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
strategy:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r test_requirements.txt
- name: Check import sorting with isort
ruff check $(git ls-files '*.py') --output-format github
- name: Run ruff formatter
run: |
isort --check $(git ls-files '*.py') --profile=black
ruff format --check $(git ls-files '*.py')
1 change: 0 additions & 1 deletion server/controllers/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

@ApiRoute("auth/create", ApiVersion.V1)
class UserCreateController(BaseAPIController):

async def post(self):
data = escape.json_decode(self.request.body)

Expand Down
3 changes: 0 additions & 3 deletions server/controllers/api/rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ async def get(self):

@ApiRoute("rbac/user/roles", ApiVersion.V1)
class RBACUserRolesHandler(BaseAPIController):

@api_authenticated
async def get(self):
with self.make_session() as session:
Expand All @@ -117,7 +116,6 @@ async def get(self):

@ApiRoute("rbac/user/roles/grant", ApiVersion.V1)
class RBACRolesGrantHandler(BaseAPIController):

@api_authenticated
@require_admin
async def post(self):
Expand Down Expand Up @@ -175,7 +173,6 @@ async def post(self):

@ApiRoute("rbac/user/roles/revoke", ApiVersion.V1)
class RBACRolesRevokeHandler(BaseAPIController):

@api_authenticated
@require_admin
async def post(self):
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/api/show/acts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

@ApiRoute("show/act", ApiVersion.V1)
class ActController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -212,7 +211,6 @@ async def delete(self):

@ApiRoute("show/act/first_scene", ApiVersion.V1)
class FirstSceneController(BaseAPIController):

@requires_show
@no_live_session
async def post(self):
Expand Down
1 change: 0 additions & 1 deletion server/controllers/api/show/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@ApiRoute("show/cast", ApiVersion.V1)
class CastController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/api/show/characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@ApiRoute("show/character", ApiVersion.V1)
class CharacterController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -222,7 +221,6 @@ async def get(self):

@ApiRoute("show/character/group", ApiVersion.V1)
class CharacterGroupController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/api/show/cues.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

@ApiRoute("show/cues/types", ApiVersion.V1)
class CueTypesController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -165,7 +164,6 @@ async def delete(self):

@ApiRoute("show/cues", ApiVersion.V1)
class CueController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/api/show/microphones.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@ApiRoute("show/microphones", ApiVersion.V1)
class MicrophoneController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -181,7 +180,6 @@ async def delete(self):

@ApiRoute("show/microphones/allocations", ApiVersion.V1)
class MicrophoneAllocationsController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
1 change: 0 additions & 1 deletion server/controllers/api/show/scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

@ApiRoute("show/scene", ApiVersion.V1)
class SceneController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/api/show/script/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

@ApiRoute("show/script/revisions", ApiVersion.V1)
class ScriptRevisionsController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -244,7 +243,6 @@ async def delete(self):

@ApiRoute("show/script/revisions/current", ApiVersion.V1)
class ScriptCurrentRevisionController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
88 changes: 42 additions & 46 deletions server/controllers/api/show/script/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

@ApiRoute("/show/script", ApiVersion.V1)
class ScriptController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -177,7 +176,6 @@ async def post(self):

previous_line: Optional[ScriptLineRevisionAssociation] = None
for index, line in enumerate(lines):

# Validate each line before we do anything with it
valid_status, valid_reason = self._validate_line(line)
if not valid_status:
Expand Down Expand Up @@ -508,13 +506,13 @@ async def patch(self):
session.flush()

if previous_line.next_line:
next_association: (
ScriptLineRevisionAssociation
) = session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": previous_line.next_line.id,
}
next_association: ScriptLineRevisionAssociation = (
session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": previous_line.next_line.id,
}
)
)
next_association.previous_line = line_object
line_association.next_line = next_association.line
Expand All @@ -535,50 +533,50 @@ async def patch(self):
and curr_association.previous_line
):
# Next line and previous line, so need to update both
next_association: (
ScriptLineRevisionAssociation
) = session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.next_line.id,
}
next_association: ScriptLineRevisionAssociation = (
session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.next_line.id,
}
)
)
next_association.previous_line = (
curr_association.previous_line
)
session.flush()

prev_association: (
ScriptLineRevisionAssociation
) = session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.previous_line.id,
}
prev_association: ScriptLineRevisionAssociation = (
session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.previous_line.id,
}
)
)
prev_association.next_line = next_association.line
session.flush()
elif curr_association.next_line:
# No previous line, so need to update next line only
next_association: (
ScriptLineRevisionAssociation
) = session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.next_line.id,
}
next_association: ScriptLineRevisionAssociation = (
session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.next_line.id,
}
)
)
next_association.previous_line = None
session.flush()
elif curr_association.previous_line:
# No next line, so need to update previous line only
prev_association: (
ScriptLineRevisionAssociation
) = session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.previous_line.id,
}
prev_association: ScriptLineRevisionAssociation = (
session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.previous_line.id,
}
)
)
prev_association.next_line = None
session.flush()
Expand Down Expand Up @@ -616,13 +614,13 @@ async def patch(self):
curr_association.previous_line = previous_line.line

if curr_association.next_line:
next_association: (
ScriptLineRevisionAssociation
) = session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.next_line.id,
}
next_association: ScriptLineRevisionAssociation = (
session.query(ScriptLineRevisionAssociation).get(
{
"revision_id": revision.id,
"line_id": curr_association.next_line.id,
}
)
)
next_association.previous_line = line_object
session.flush()
Expand Down Expand Up @@ -687,7 +685,6 @@ def get(self):

@ApiRoute("/show/script/cuts", ApiVersion.V1)
class ScriptCutsController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down Expand Up @@ -787,7 +784,6 @@ def put(self):

@ApiRoute("/show/script/max_page", ApiVersion.V1)
class ScriptMaxPageController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
1 change: 0 additions & 1 deletion server/controllers/api/show/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

@ApiRoute("show/sessions", ApiVersion.V1)
class SessionsController(BaseAPIController):

@requires_show
def get(self):
current_show = self.get_current_show()
Expand Down
2 changes: 0 additions & 2 deletions server/controllers/api/show/shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

@ApiRoute("show", ApiVersion.V1)
class ShowController(BaseAPIController):

@api_authenticated
@require_admin
async def post(self):
Expand Down Expand Up @@ -207,7 +206,6 @@ async def patch(self):

@ApiRoute("shows", ApiVersion.V1)
class ShowsController(BaseAPIController):

def get(self):
shows = []
show_schema = ShowSchema()
Expand Down
1 change: 0 additions & 1 deletion server/controllers/api/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

@ApiRoute("ws/sessions", ApiVersion.V1)
class WebsocketSessionsController(BaseAPIController):

def get(self):
session_scheme = SessionSchema()
with self.make_session() as session:
Expand Down
1 change: 1 addition & 0 deletions server/controllers/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from utils.web.base_controller import BaseAPIController, BaseController
from utils.web.route import ApiRoute, ApiVersion, Route


IMPORTED_CONTROLLERS = {}


Expand Down
Loading
Loading