Skip to content

Commit

Permalink
build: Update pre-commit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzWeber0 committed Feb 16, 2024
1 parent 624d3c1 commit 2c014d1
Show file tree
Hide file tree
Showing 21 changed files with 93 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
- id: fix-byte-order-marker
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.2.0
hooks:
- id: black
files: '^backend/'
Expand Down Expand Up @@ -78,7 +78,7 @@ repos:
- 'prettier@^3.0.3'
- 'prettier-plugin-tailwindcss@^0.5.5'
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
rev: v1.5.5
hooks:
- id: insert-license
name: Insert license headers (shell-style comments)
Expand Down
5 changes: 3 additions & 2 deletions backend/capellacollab/core/authentication/injectables.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ def __init__(
self,
required_role: projects_users_models.ProjectUserRole,
verify: bool = True,
required_permission: projects_users_models.ProjectUserPermission
| None = None,
required_permission: (
projects_users_models.ProjectUserPermission | None
) = None,
):
self.required_role = required_role
self.verify = verify
Expand Down
6 changes: 3 additions & 3 deletions backend/capellacollab/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class DatabaseUserHistoryEvent(database.Base):
sa.ForeignKey("projects.id"),
init=False,
)
project: orm.Mapped[
projects_models.DatabaseProject | None
] = orm.relationship(default=None, foreign_keys=[project_id])
project: orm.Mapped[projects_models.DatabaseProject | None] = (
orm.relationship(default=None, foreign_keys=[project_id])
)

execution_time: orm.Mapped[datetime.datetime] = orm.mapped_column(
default=datetime.datetime.now(datetime.UTC)
Expand Down
14 changes: 7 additions & 7 deletions backend/capellacollab/projects/toolmodels/backups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ class DatabaseBackup(database.Base):
)
model: orm.Mapped["DatabaseToolModel"] = orm.relationship()

runs: orm.Mapped[
list["runs_models.DatabasePipelineRun"]
] = orm.relationship(
"DatabasePipelineRun",
back_populates="pipeline",
cascade="all, delete-orphan",
default_factory=list,
runs: orm.Mapped[list["runs_models.DatabasePipelineRun"]] = (
orm.relationship(
"DatabasePipelineRun",
back_populates="pipeline",
cascade="all, delete-orphan",
default_factory=list,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class DatabasePipelineRun(Base):
end_time: orm.Mapped[datetime.datetime | None] = orm.mapped_column(
default=None
)
logs_last_fetched_timestamp: orm.Mapped[
datetime.datetime | None
] = orm.mapped_column(default=None)
logs_last_fetched_timestamp: orm.Mapped[datetime.datetime | None] = (
orm.mapped_column(default=None)
)


class PipelineRun(pydantic.BaseModel):
Expand Down
14 changes: 7 additions & 7 deletions backend/capellacollab/projects/toolmodels/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ class DatabaseToolModel(database.Base):
default_factory=list, back_populates="model"
)

restrictions: orm.Mapped[
DatabaseToolModelRestrictions | None
] = orm.relationship(
back_populates="model",
uselist=False,
cascade="delete",
default=None,
restrictions: orm.Mapped[DatabaseToolModelRestrictions | None] = (
orm.relationship(
back_populates="model",
uselist=False,
cascade="delete",
default=None,
)
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ def get_last_updated_for_file_path(
) -> datetime.datetime | None:
response = requests.get(
f"{self.git_instance.api_url}/repos/{project_id}/commits?path={file_path}&sha={revision or self.git_model.revision}",
headers=self.__get_headers(self.git_model.password)
if self.git_model.password
else None,
headers=(
self.__get_headers(self.git_model.password)
if self.git_model.password
else None
),
timeout=config["requests"]["timeout"],
)
response.raise_for_status()
Expand Down
8 changes: 5 additions & 3 deletions backend/capellacollab/sessions/hooks/t4c.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def configuration_hook( # type: ignore
{
"repository": repository.name,
"protocol": repository.instance.protocol,
"port": repository.instance.http_port
if repository.instance.protocol == "ws"
else repository.instance.port,
"port": (
repository.instance.http_port
if repository.instance.protocol == "ws"
else repository.instance.port
),
"host": repository.instance.host,
"instance": repository.instance.name,
}
Expand Down
6 changes: 3 additions & 3 deletions backend/capellacollab/sessions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ class DatabaseSession(database.Base):
project_id: orm.Mapped[str | None] = orm.mapped_column(
sa.ForeignKey("projects.id"), init=False
)
project: orm.Mapped[
projects_models.DatabaseProject | None
] = orm.relationship()
project: orm.Mapped[projects_models.DatabaseProject | None] = (
orm.relationship()
)

environment: orm.Mapped[dict[str, str] | None]

Expand Down
12 changes: 6 additions & 6 deletions backend/capellacollab/sessions/operators/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ def _get_pod_state(self, label_selector: str):
log.debug("Received k8s pod: %s", pod_name)
log.debug("Fetching k8s events for pod: %s", pod_name)

events: list[
client.CoreV1Event
] = self.v1_core.list_namespaced_event(
namespace=namespace,
field_selector=f"involvedObject.name={pod_name}",
).items
events: list[client.CoreV1Event] = (

Check warning on line 276 in backend/capellacollab/sessions/operators/k8s.py

View check run for this annotation

Codecov / codecov/patch

backend/capellacollab/sessions/operators/k8s.py#L276

Added line #L276 was not covered by tests
self.v1_core.list_namespaced_event(
namespace=namespace,
field_selector=f"involvedObject.name={pod_name}",
).items
)

events = list(filter(self._is_non_promtail_event, events))
if events:
Expand Down
12 changes: 6 additions & 6 deletions backend/capellacollab/tools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class DatabaseTool(database.Base):
default=None
)

integrations: orm.Mapped[
DatabaseToolIntegrations | None
] = orm.relationship(
default=None,
back_populates="tool",
uselist=False,
integrations: orm.Mapped[DatabaseToolIntegrations | None] = (
orm.relationship(
default=None,
back_populates="tool",
uselist=False,
)
)

versions: orm.Mapped[list[DatabaseVersion]] = orm.relationship(
Expand Down
12 changes: 6 additions & 6 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def fixture_admin(
def get_mock_own_user():
return admin

app.dependency_overrides[
users_injectables.get_own_user
] = get_mock_own_user
app.dependency_overrides[users_injectables.get_own_user] = (
get_mock_own_user
)
yield admin
del app.dependency_overrides[users_injectables.get_own_user]

Expand All @@ -110,9 +110,9 @@ def fixture_user(
def get_mock_own_user():
return user

app.dependency_overrides[
users_injectables.get_own_user
] = get_mock_own_user
app.dependency_overrides[users_injectables.get_own_user] = (
get_mock_own_user
)
yield user
del app.dependency_overrides[users_injectables.get_own_user]

Expand Down
23 changes: 13 additions & 10 deletions backend/tests/projects/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ def fixture_override_dependency(mock_project):
def override_get_existing_project():
return mock_project

app.dependency_overrides[
projects_injectables.get_existing_project
] = override_get_existing_project
app.dependency_overrides[projects_injectables.get_existing_project] = (
override_get_existing_project
)
yield
del app.dependency_overrides[projects_injectables.get_existing_project]

Expand All @@ -257,13 +257,16 @@ def test_delete_pipeline_called_when_archiving_project(
users_crud.create_user(db, executor_name, users_models.Role.ADMIN)
mock_project.models = [mock_model]

with mock.patch(
"capellacollab.projects.routes.backups_core.delete_pipeline",
autospec=True,
) as mock_delete_pipeline, mock.patch(
"capellacollab.projects.routes.backups_crud.get_pipelines_for_tool_model",
autospec=True,
) as mock_get_pipelines_for_tool_model:
with (
mock.patch(
"capellacollab.projects.routes.backups_core.delete_pipeline",
autospec=True,
) as mock_delete_pipeline,
mock.patch(
"capellacollab.projects.routes.backups_crud.get_pipelines_for_tool_model",
autospec=True,
) as mock_get_pipelines_for_tool_model,
):
mock_get_pipelines_for_tool_model.return_value = [mock_pipeline]

response = client.patch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def fixture_override_get_existing_pipeline_run_dependency(
def get_mock_existing_pipeline_run() -> runs_models.DatabasePipelineRun:
return mock_pipeline_run

app.dependency_overrides[
runs_injectables.get_existing_pipeline_run
] = get_mock_existing_pipeline_run
app.dependency_overrides[runs_injectables.get_existing_pipeline_run] = (
get_mock_existing_pipeline_run
)

yield

Expand Down
6 changes: 3 additions & 3 deletions backend/tests/projects/toolmodels/test_toolmodel_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def fixture_override_dependency():
mock_model.slug = "any-slug"
mock_model.tool = mock.Mock(name="tool")

app.dependency_overrides[
projects_injectables.get_existing_project
] = lambda: mock_project
app.dependency_overrides[projects_injectables.get_existing_project] = (
lambda: mock_project
)
app.dependency_overrides[
toolmodels_injectables.get_existing_capella_model
] = lambda: mock_model
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/sessions/test_session_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def fixture_mockoperator() -> t.Generator[MockOperator, None, None]:
def get_mock_operator():
return mock

__main__.app.dependency_overrides[
operators.get_operator
] = get_mock_operator
__main__.app.dependency_overrides[operators.get_operator] = (
get_mock_operator
)
yield mock
del __main__.app.dependency_overrides[operators.get_operator]

Expand Down
6 changes: 3 additions & 3 deletions backend/tests/sessions/test_sessions_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def fixture_user(
def get_mock_own_user():
return user

app.dependency_overrides[
users_injectables.get_own_user
] = get_mock_own_user
app.dependency_overrides[users_injectables.get_own_user] = (
get_mock_own_user
)
yield user
del app.dependency_overrides[users_injectables.get_own_user]

Expand Down
6 changes: 3 additions & 3 deletions backend/tests/settings/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def test_create_alert2(

assert response.status_code == 200

notices: abc.Sequence[
notices_models.DatabaseNotice
] = notices_crud.get_notices(db)
notices: abc.Sequence[notices_models.DatabaseNotice] = (
notices_crud.get_notices(db)
)
assert len(notices) == 1
assert notices[0].title == "test"
assert notices[0].message == "test"
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/settings/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def test_metadata_is_updated(
def get_mock_own_user():
return admin

app.dependency_overrides[
users_injectables.get_own_user
] = get_mock_own_user
app.dependency_overrides[users_injectables.get_own_user] = (
get_mock_own_user
)

response = client.put(
"/api/v1/settings/configurations/global",
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/test_event_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def test_create_admin_user_by_system(db):
db, config.config["initial"]["admin"]
)

events: list[
events_models.DatabaseUserHistoryEvent
] = get_events_by_user_id(db, user.id)
events: list[events_models.DatabaseUserHistoryEvent] = (
get_events_by_user_id(db, user.id)
)

assert len(events) == 1

Expand Down
6 changes: 3 additions & 3 deletions backend/tests/users/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def fixture_unauthenticated_user(db):
def get_mock_own_user():
return user

app.dependency_overrides[
users_injectables.get_own_user
] = get_mock_own_user
app.dependency_overrides[users_injectables.get_own_user] = (
get_mock_own_user
)
yield user
del app.dependency_overrides[users_injectables.get_own_user]

0 comments on commit 2c014d1

Please sign in to comment.