diff --git a/selfprivacy_api/actions/api_tokens.py b/selfprivacy_api/actions/api_tokens.py index e93491f..af4bde5 100644 --- a/selfprivacy_api/actions/api_tokens.py +++ b/selfprivacy_api/actions/api_tokens.py @@ -1,7 +1,8 @@ """ -App tokens actions. +App tokens actions. The only actions on tokens that are accessible from APIs """ + from datetime import datetime, timezone from typing import Optional from pydantic import BaseModel diff --git a/selfprivacy_api/actions/ssh.py b/selfprivacy_api/actions/ssh.py index 0c529ef..291ca7b 100644 --- a/selfprivacy_api/actions/ssh.py +++ b/selfprivacy_api/actions/ssh.py @@ -1,4 +1,5 @@ """Actions to manage the SSH.""" + from typing import Optional from pydantic import BaseModel from selfprivacy_api.actions.users import ( diff --git a/selfprivacy_api/actions/system.py b/selfprivacy_api/actions/system.py index 9b52497..4b1c6fd 100644 --- a/selfprivacy_api/actions/system.py +++ b/selfprivacy_api/actions/system.py @@ -1,4 +1,5 @@ """Actions to manage the system.""" + import os import subprocess import pytz diff --git a/selfprivacy_api/actions/users.py b/selfprivacy_api/actions/users.py index fafa84f..7dd83fa 100644 --- a/selfprivacy_api/actions/users.py +++ b/selfprivacy_api/actions/users.py @@ -1,4 +1,5 @@ """Actions to manage the users.""" + import re from typing import Optional from pydantic import BaseModel diff --git a/selfprivacy_api/backup/__init__.py b/selfprivacy_api/backup/__init__.py index bf111aa..c632a00 100644 --- a/selfprivacy_api/backup/__init__.py +++ b/selfprivacy_api/backup/__init__.py @@ -1,6 +1,7 @@ """ This module contains the controller class for backups. """ + from datetime import datetime, timedelta, timezone import time import os diff --git a/selfprivacy_api/backup/providers/provider.py b/selfprivacy_api/backup/providers/provider.py index 077e920..584ad86 100644 --- a/selfprivacy_api/backup/providers/provider.py +++ b/selfprivacy_api/backup/providers/provider.py @@ -3,7 +3,8 @@ An abstract class for BackBlaze, S3 etc. It assumes that while some providers are supported via restic/rclone, others may require different backends """ -from abc import ABC, abstractmethod + +from abc import ABC from selfprivacy_api.backup.backuppers import AbstractBackupper from selfprivacy_api.graphql.queries.providers import ( BackupProvider as BackupProviderEnum, diff --git a/selfprivacy_api/backup/storage.py b/selfprivacy_api/backup/storage.py index dd9bb26..d2b6c09 100644 --- a/selfprivacy_api/backup/storage.py +++ b/selfprivacy_api/backup/storage.py @@ -1,6 +1,7 @@ """ Module for storing backup related data in redis. """ + from typing import List, Optional from datetime import datetime diff --git a/selfprivacy_api/backup/tasks.py b/selfprivacy_api/backup/tasks.py index 7478cc2..89f2684 100644 --- a/selfprivacy_api/backup/tasks.py +++ b/selfprivacy_api/backup/tasks.py @@ -1,6 +1,7 @@ """ The tasks module contains the worker tasks that are used to back up and restore """ + from datetime import datetime, timezone from selfprivacy_api.graphql.common_types.backup import ( diff --git a/selfprivacy_api/graphql/__init__.py b/selfprivacy_api/graphql/__init__.py index edd8a78..a0e9036 100644 --- a/selfprivacy_api/graphql/__init__.py +++ b/selfprivacy_api/graphql/__init__.py @@ -1,4 +1,5 @@ """GraphQL API for SelfPrivacy.""" + # pylint: disable=too-few-public-methods import typing from strawberry.permission import BasePermission diff --git a/selfprivacy_api/graphql/common_types/backup.py b/selfprivacy_api/graphql/common_types/backup.py index 953009d..a03413a 100644 --- a/selfprivacy_api/graphql/common_types/backup.py +++ b/selfprivacy_api/graphql/common_types/backup.py @@ -1,4 +1,5 @@ """Backup""" + # pylint: disable=too-few-public-methods from enum import Enum import strawberry diff --git a/selfprivacy_api/graphql/common_types/jobs.py b/selfprivacy_api/graphql/common_types/jobs.py index 1a644ec..df4b5c4 100644 --- a/selfprivacy_api/graphql/common_types/jobs.py +++ b/selfprivacy_api/graphql/common_types/jobs.py @@ -1,4 +1,5 @@ """Jobs status""" + # pylint: disable=too-few-public-methods import datetime import typing diff --git a/selfprivacy_api/graphql/common_types/service.py b/selfprivacy_api/graphql/common_types/service.py index fb6c972..af57399 100644 --- a/selfprivacy_api/graphql/common_types/service.py +++ b/selfprivacy_api/graphql/common_types/service.py @@ -247,9 +247,9 @@ def get_volume_by_id(volume_id: str) -> Optional[StorageVolume]: if volume is None: return None return StorageVolume( - total_space=str(volume.fssize) - if volume.fssize is not None - else str(volume.size), + total_space=( + str(volume.fssize) if volume.fssize is not None else str(volume.size) + ), free_space=str(volume.fsavail), used_space=str(volume.fsused), root=volume.name == "sda1", diff --git a/selfprivacy_api/graphql/mutations/api_mutations.py b/selfprivacy_api/graphql/mutations/api_mutations.py index 49c49ad..d6b7a07 100644 --- a/selfprivacy_api/graphql/mutations/api_mutations.py +++ b/selfprivacy_api/graphql/mutations/api_mutations.py @@ -1,4 +1,5 @@ """API access mutations""" + # pylint: disable=too-few-public-methods import datetime import typing diff --git a/selfprivacy_api/graphql/mutations/job_mutations.py b/selfprivacy_api/graphql/mutations/job_mutations.py index acc5f3d..64347d3 100644 --- a/selfprivacy_api/graphql/mutations/job_mutations.py +++ b/selfprivacy_api/graphql/mutations/job_mutations.py @@ -1,4 +1,5 @@ """Manipulate jobs""" + # pylint: disable=too-few-public-methods import strawberry diff --git a/selfprivacy_api/graphql/mutations/services_mutations.py b/selfprivacy_api/graphql/mutations/services_mutations.py index 34f9539..ae584d0 100644 --- a/selfprivacy_api/graphql/mutations/services_mutations.py +++ b/selfprivacy_api/graphql/mutations/services_mutations.py @@ -1,4 +1,5 @@ """Services mutations""" + # pylint: disable=too-few-public-methods import typing import strawberry diff --git a/selfprivacy_api/graphql/mutations/storage_mutations.py b/selfprivacy_api/graphql/mutations/storage_mutations.py index 243220b..d39ef52 100644 --- a/selfprivacy_api/graphql/mutations/storage_mutations.py +++ b/selfprivacy_api/graphql/mutations/storage_mutations.py @@ -1,4 +1,5 @@ """Storage devices mutations""" + import strawberry from selfprivacy_api.graphql import IsAuthenticated from selfprivacy_api.graphql.common_types.jobs import job_to_api_job diff --git a/selfprivacy_api/graphql/mutations/system_mutations.py b/selfprivacy_api/graphql/mutations/system_mutations.py index d72b630..a4435db 100644 --- a/selfprivacy_api/graphql/mutations/system_mutations.py +++ b/selfprivacy_api/graphql/mutations/system_mutations.py @@ -1,4 +1,5 @@ """System management mutations""" + # pylint: disable=too-few-public-methods import typing import strawberry diff --git a/selfprivacy_api/graphql/queries/logs.py b/selfprivacy_api/graphql/queries/logs.py index 11861ec..50ef2c2 100644 --- a/selfprivacy_api/graphql/queries/logs.py +++ b/selfprivacy_api/graphql/queries/logs.py @@ -1,4 +1,5 @@ """System logs""" + from datetime import datetime import typing import strawberry diff --git a/selfprivacy_api/graphql/schema.py b/selfprivacy_api/graphql/schema.py index 761bd24..eb94922 100644 --- a/selfprivacy_api/graphql/schema.py +++ b/selfprivacy_api/graphql/schema.py @@ -1,4 +1,5 @@ """GraphQL API for SelfPrivacy.""" + # pylint: disable=too-few-public-methods import asyncio diff --git a/selfprivacy_api/jobs/__init__.py b/selfprivacy_api/jobs/__init__.py index 3dd48c4..f4dc5da 100644 --- a/selfprivacy_api/jobs/__init__.py +++ b/selfprivacy_api/jobs/__init__.py @@ -14,6 +14,7 @@ A job is a dictionary with the following keys: - error: error message if the job failed - result: result of the job """ + import typing import asyncio import datetime diff --git a/selfprivacy_api/jobs/migrate_to_binds.py b/selfprivacy_api/jobs/migrate_to_binds.py index 782b361..7ab1cd5 100644 --- a/selfprivacy_api/jobs/migrate_to_binds.py +++ b/selfprivacy_api/jobs/migrate_to_binds.py @@ -1,4 +1,5 @@ """Function to perform migration of app data to binds.""" + import subprocess import pathlib import shutil diff --git a/selfprivacy_api/jobs/upgrade_system.py b/selfprivacy_api/jobs/upgrade_system.py index ab16120..d1cb0be 100644 --- a/selfprivacy_api/jobs/upgrade_system.py +++ b/selfprivacy_api/jobs/upgrade_system.py @@ -3,6 +3,7 @@ A task to start the system upgrade or rebuild by starting a systemd unit. After starting, track the status of the systemd unit and update the Job status accordingly. """ + import subprocess from selfprivacy_api.utils.huey import huey from selfprivacy_api.jobs import JobStatus, Jobs, Job diff --git a/selfprivacy_api/migrations/add_roundcube.py b/selfprivacy_api/migrations/add_roundcube.py index 68505ea..a1223a8 100644 --- a/selfprivacy_api/migrations/add_roundcube.py +++ b/selfprivacy_api/migrations/add_roundcube.py @@ -22,6 +22,6 @@ class AddRoundcube(Migration): def migrate(self) -> None: with FlakeServiceManager() as manager: if "roundcube" not in manager.services: - manager.services[ - "roundcube" - ] = "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/roundcube" + manager.services["roundcube"] = ( + "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/roundcube" + ) diff --git a/selfprivacy_api/models/tokens/new_device_key.py b/selfprivacy_api/models/tokens/new_device_key.py index 241cbd3..55cf824 100644 --- a/selfprivacy_api/models/tokens/new_device_key.py +++ b/selfprivacy_api/models/tokens/new_device_key.py @@ -1,6 +1,7 @@ """ New device key used to obtain access token. """ + from datetime import datetime, timedelta, timezone import secrets from pydantic import BaseModel diff --git a/selfprivacy_api/models/tokens/recovery_key.py b/selfprivacy_api/models/tokens/recovery_key.py index 3f52735..6e78f2c 100644 --- a/selfprivacy_api/models/tokens/recovery_key.py +++ b/selfprivacy_api/models/tokens/recovery_key.py @@ -3,6 +3,7 @@ Recovery key used to obtain access token. Recovery key has a token string, date of creation, optional date of expiration and optional count of uses left. """ + from datetime import datetime, timezone import secrets from typing import Optional diff --git a/selfprivacy_api/models/tokens/token.py b/selfprivacy_api/models/tokens/token.py index 4c34f58..a1ed09d 100644 --- a/selfprivacy_api/models/tokens/token.py +++ b/selfprivacy_api/models/tokens/token.py @@ -3,6 +3,7 @@ Model of the access token. Access token has a token string, device name and date of creation. """ + from datetime import datetime import secrets from pydantic import BaseModel diff --git a/selfprivacy_api/repositories/tokens/redis_tokens_repository.py b/selfprivacy_api/repositories/tokens/redis_tokens_repository.py index 35ff1da..b7b4dd6 100644 --- a/selfprivacy_api/repositories/tokens/redis_tokens_repository.py +++ b/selfprivacy_api/repositories/tokens/redis_tokens_repository.py @@ -1,6 +1,7 @@ """ Token repository using Redis as backend. """ + from typing import Any, Optional from datetime import datetime from hashlib import md5 diff --git a/selfprivacy_api/services/bitwarden/__init__.py b/selfprivacy_api/services/bitwarden/__init__.py index 4614c15..358cb7e 100644 --- a/selfprivacy_api/services/bitwarden/__init__.py +++ b/selfprivacy_api/services/bitwarden/__init__.py @@ -1,4 +1,5 @@ """Class representing Bitwarden service""" + import base64 import subprocess from typing import List diff --git a/selfprivacy_api/services/forgejo/__init__.py b/selfprivacy_api/services/forgejo/__init__.py index a5b07b0..d9e527b 100644 --- a/selfprivacy_api/services/forgejo/__init__.py +++ b/selfprivacy_api/services/forgejo/__init__.py @@ -1,4 +1,5 @@ """Class representing Bitwarden service""" + import base64 import subprocess from typing import List diff --git a/selfprivacy_api/services/generic_size_counter.py b/selfprivacy_api/services/generic_size_counter.py index 71dff82..9bb6baa 100644 --- a/selfprivacy_api/services/generic_size_counter.py +++ b/selfprivacy_api/services/generic_size_counter.py @@ -1,4 +1,5 @@ """Generic size counter using pathlib""" + import pathlib diff --git a/selfprivacy_api/services/jitsimeet/__init__.py b/selfprivacy_api/services/jitsimeet/__init__.py index 0bf0370..39b9bff 100644 --- a/selfprivacy_api/services/jitsimeet/__init__.py +++ b/selfprivacy_api/services/jitsimeet/__init__.py @@ -1,4 +1,5 @@ """Class representing Jitsi Meet service""" + import base64 import subprocess from typing import List diff --git a/selfprivacy_api/services/nextcloud/__init__.py b/selfprivacy_api/services/nextcloud/__init__.py index 4cd0156..cd66dfa 100644 --- a/selfprivacy_api/services/nextcloud/__init__.py +++ b/selfprivacy_api/services/nextcloud/__init__.py @@ -1,4 +1,5 @@ """Class representing Nextcloud service.""" + import base64 import subprocess from typing import List diff --git a/selfprivacy_api/services/ocserv/__init__.py b/selfprivacy_api/services/ocserv/__init__.py index 818b1d8..c180f62 100644 --- a/selfprivacy_api/services/ocserv/__init__.py +++ b/selfprivacy_api/services/ocserv/__init__.py @@ -1,4 +1,5 @@ """Class representing ocserv service.""" + import base64 import subprocess import typing diff --git a/selfprivacy_api/services/pleroma/__init__.py b/selfprivacy_api/services/pleroma/__init__.py index e300844..0c260a8 100644 --- a/selfprivacy_api/services/pleroma/__init__.py +++ b/selfprivacy_api/services/pleroma/__init__.py @@ -1,4 +1,5 @@ """Class representing Nextcloud service.""" + import base64 import subprocess from typing import List diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 17b6f4f..8764c38 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -1,4 +1,5 @@ """Abstract class for a service running on a server""" + from abc import ABC, abstractmethod from typing import List, Optional diff --git a/selfprivacy_api/services/test_service/__init__.py b/selfprivacy_api/services/test_service/__init__.py index 1a2fd9d..6bc796e 100644 --- a/selfprivacy_api/services/test_service/__init__.py +++ b/selfprivacy_api/services/test_service/__init__.py @@ -1,4 +1,5 @@ """Class representing Bitwarden service""" + import base64 import subprocess diff --git a/selfprivacy_api/utils/block_devices.py b/selfprivacy_api/utils/block_devices.py index 0db8fe0..6b90091 100644 --- a/selfprivacy_api/utils/block_devices.py +++ b/selfprivacy_api/utils/block_devices.py @@ -1,4 +1,5 @@ """A block device API wrapping lsblk""" + from __future__ import annotations import subprocess import json diff --git a/selfprivacy_api/utils/huey.py b/selfprivacy_api/utils/huey.py index 1a7a29d..f27e662 100644 --- a/selfprivacy_api/utils/huey.py +++ b/selfprivacy_api/utils/huey.py @@ -1,4 +1,5 @@ """MiniHuey singleton.""" + from os import environ from huey import RedisHuey diff --git a/selfprivacy_api/utils/singleton_metaclass.py b/selfprivacy_api/utils/singleton_metaclass.py index 685cef6..5c149f2 100644 --- a/selfprivacy_api/utils/singleton_metaclass.py +++ b/selfprivacy_api/utils/singleton_metaclass.py @@ -3,6 +3,7 @@ Singleton is a creational design pattern, which ensures that only one object of its kind exists and provides a single point of access to it for any other code. """ + from threading import Lock diff --git a/selfprivacy_api/utils/systemd.py b/selfprivacy_api/utils/systemd.py index 3b3ec6c..de35c01 100644 --- a/selfprivacy_api/utils/systemd.py +++ b/selfprivacy_api/utils/systemd.py @@ -1,4 +1,5 @@ """Generic service status fetcher using systemctl""" + import subprocess from typing import List diff --git a/tests/conftest.py b/tests/conftest.py index 3b28718..a3f28e4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Tests configuration.""" + # pylint: disable=redefined-outer-name # pylint: disable=unused-argument import os diff --git a/tests/test_services.py b/tests/test_services.py index de828d8..d7ea919 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -1,6 +1,7 @@ """ Tests for generic service methods """ + import pytest from pytest import raises