Skip to content

Commit

Permalink
fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Jan 7, 2025
1 parent 55c3666 commit 3c5aa64
Show file tree
Hide file tree
Showing 21 changed files with 1,342 additions and 200 deletions.
52 changes: 26 additions & 26 deletions components/renku_data_services/authz/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ def extend(self, other: "_AuthzChange") -> None:
class _Relation(StrEnum):
"""Relations for Authzed."""

owner: str = "owner"
editor: str = "editor"
viewer: str = "viewer"
public_viewer: str = "public_viewer"
admin: str = "admin"
project_platform: str = "project_platform"
group_platform: str = "group_platform"
user_namespace_platform: str = "user_namespace_platform"
project_namespace: str = "project_namespace"
data_connector_platform: str = "data_connector_platform"
data_connector_namespace: str = "data_connector_namespace"
linked_to: str = "linked_to"
owner = "owner"
editor = "editor"
viewer = "viewer"
public_viewer = "public_viewer"
admin = "admin"
project_platform = "project_platform"
group_platform = "group_platform"
user_namespace_platform = "user_namespace_platform"
project_namespace = "project_namespace"
data_connector_platform = "data_connector_platform"
data_connector_namespace = "data_connector_namespace"
linked_to = "linked_to"

@classmethod
def from_role(cls, role: Role) -> "_Relation":
Expand All @@ -156,25 +156,25 @@ def to_role(self) -> Role:
class ResourceType(StrEnum):
"""All possible resources stored in Authzed."""

project: str = "project"
user: str = "user"
anonymous_user: str = "anonymous_user"
platform: str = "platform"
group: str = "group"
user_namespace: str = "user_namespace"
data_connector: str = "data_connector"
project = "project"
user = "user"
anonymous_user = "anonymous_user"
platform = "platform"
group = "group"
user_namespace = "user_namespace"
data_connector = "data_connector"


class AuthzOperation(StrEnum):
"""The type of change that requires authorization database update."""

create: str = "create"
delete: str = "delete"
update: str = "update"
update_or_insert: str = "update_or_insert"
insert_many: str = "insert_many"
create_link: str = "create_link"
delete_link: str = "delete_link"
create = "create"
delete = "delete"
update = "update"
update_or_insert = "update_or_insert"
insert_many = "insert_many"
create_link = "create_link"
delete_link = "delete_link"


class _AuthzConverter:
Expand Down
36 changes: 18 additions & 18 deletions components/renku_data_services/authz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
class Role(Enum):
"""Membership role."""

OWNER: str = "owner"
VIEWER: str = "viewer"
EDITOR: str = "editor"
OWNER = "owner"
VIEWER = "viewer"
EDITOR = "editor"

@classmethod
def from_group_role(cls, role: GroupRole) -> "Role":
Expand All @@ -36,11 +36,11 @@ def from_group_role(cls, role: GroupRole) -> "Role":
def to_group_role(self) -> GroupRole:
"""Convert a group role into an authorization role."""
match self:
case self.OWNER:
case Role.OWNER:
return GroupRole.owner
case self.EDITOR:
case Role.EDITOR:
return GroupRole.editor
case self.VIEWER:
case Role.VIEWER:
return GroupRole.viewer
case _:
raise errors.ProgrammingError(message=f"Could not convert role {self} into a group role")
Expand All @@ -49,13 +49,13 @@ def to_group_role(self) -> GroupRole:
class Scope(Enum):
"""Types of permissions - i.e. scope."""

READ: str = "read"
WRITE: str = "write"
DELETE: str = "delete"
CHANGE_MEMBERSHIP: str = "change_membership"
READ_CHILDREN: str = "read_children"
ADD_LINK: str = "add_link"
IS_ADMIN: str = "is_admin"
READ = "read"
WRITE = "write"
DELETE = "delete"
CHANGE_MEMBERSHIP = "change_membership"
READ_CHILDREN = "read_children"
ADD_LINK = "add_link"
IS_ADMIN = "is_admin"


@dataclass
Expand All @@ -80,9 +80,9 @@ class Member(UnsavedMember):
class Change(Enum):
"""The type of change executed on a specific resource."""

UPDATE: str = "update"
ADD: str = "add"
REMOVE: str = "remove"
UPDATE = "update"
ADD = "add"
REMOVE = "remove"


@dataclass
Expand All @@ -96,8 +96,8 @@ class MembershipChange:
class Visibility(Enum):
"""The visibility of a resource."""

PUBLIC: str = "public"
PRIVATE: str = "private"
PUBLIC = "public"
PRIVATE = "private"


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def message_wrapper(self: _WithMessageQueue, *args: _P.args, **kwargs: _P.
)
result = await f(self, *args, **kwargs)
if result is None:
return result # type: ignore[unreachable]
return result
events = EventConverter.to_events(result, event_type)

for event in events:
Expand Down
4 changes: 2 additions & 2 deletions components/renku_data_services/namespace/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class GroupMemberDetails:
class NamespaceKind(str, Enum):
"""Allowed kinds of namespaces."""

group: str = "group"
user: str = "user"
group = "group"
user = "user"


@dataclass
Expand Down
8 changes: 4 additions & 4 deletions components/renku_data_services/notebooks/api/classes/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
class ManifestTypes(Enum):
"""The mime types for docker image manifests."""

docker_v2: str = "application/vnd.docker.distribution.manifest.v2+json"
docker_v2_list: str = "application/vnd.docker.distribution.manifest.list.v2+json"
oci_v1_manifest: str = "application/vnd.oci.image.manifest.v1+json"
oci_v1_index: str = "application/vnd.oci.image.index.v1+json"
docker_v2 = "application/vnd.docker.distribution.manifest.v2+json"
docker_v2_list = "application/vnd.docker.distribution.manifest.list.v2+json"
oci_v1_manifest = "application/vnd.oci.image.manifest.v1+json"
oci_v1_index = "application/vnd.oci.image.index.v1+json"


DEFAULT_PLATFORM_ARCHITECTURE = "amd64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def list(cls) -> list[str]:
class StepStatusEnum(Enum):
"""Enum for status of a session start step."""

ready: str = "ready" # An init job completely done or container fully running
waiting: str = "waiting" # Waiting to start
executing: str = "executing" # Running but not complete or fully ready
failed: str = "failed"
ready = "ready" # An init job completely done or container fully running
waiting = "waiting" # Waiting to start
executing = "executing" # Running but not complete or fully ready
failed = "failed"

@classmethod
def list(cls) -> list[str]:
Expand Down
6 changes: 3 additions & 3 deletions components/renku_data_services/notebooks/config/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def _parse_value_as_float(val: Any) -> float:
class CPUEnforcement(str, Enum):
"""CPU enforcement policies."""

LAX: str = "lax" # CPU limit equals 3x cpu request
STRICT: str = "strict" # CPU limit equals cpu request
OFF: str = "off" # no CPU limit at all
LAX = "lax" # CPU limit equals 3x cpu request
STRICT = "strict" # CPU limit equals cpu request
OFF = "off" # no CPU limit at all


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions components/renku_data_services/notebooks/util/kubernetes_.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def _make_server_name_prefix(safe_username: str) -> str:
class PatchKind(StrEnum):
"""Content types for different json patches."""

json: str = "application/json-patch+json"
merge: str = "application/merge-patch+json"
json = "application/json-patch+json"
merge = "application/merge-patch+json"


def find_container(patches: list[Patch], container_name: str) -> dict[str, Any] | None:
Expand Down
4 changes: 2 additions & 2 deletions components/renku_data_services/session/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Member:
class EnvironmentKind(StrEnum):
"""The type of environment."""

GLOBAL: str = "GLOBAL"
CUSTOM: str = "CUSTOM"
GLOBAL = "GLOBAL"
CUSTOM = "CUSTOM"


@dataclass(kw_only=True, frozen=True, eq=True)
Expand Down
10 changes: 5 additions & 5 deletions components/renku_data_services/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
class KeycloakEvent(Enum):
"""The Keycloak user events that result from the user registering or updating their personal information."""

REGISTER: str = "REGISTER"
UPDATE_PROFILE: str = "UPDATE_PROFILE"
REGISTER = "REGISTER"
UPDATE_PROFILE = "UPDATE_PROFILE"


class KeycloakAdminEvent(Enum):
"""The Keycloak admin events used to keep users up to date."""

DELETE: str = "DELETE"
UPDATE: str = "UPDATE"
CREATE: str = "CREATE"
DELETE = "DELETE"
UPDATE = "UPDATE"
CREATE = "CREATE"


@dataclass
Expand Down
Loading

0 comments on commit 3c5aa64

Please sign in to comment.