Skip to content

Commit

Permalink
Sort imports in all files using isort
Browse files Browse the repository at this point in the history
  • Loading branch information
mitya57 committed Dec 23, 2024
1 parent 72cbb72 commit 7dc7258
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 36 deletions.
22 changes: 16 additions & 6 deletions secretstorage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
from jeepney.bus_messages import message_bus
from jeepney.io.blocking import DBusConnection, Proxy, open_dbus_connection

from secretstorage.collection import Collection, create_collection, \
get_all_collections, get_default_collection, get_any_collection, \
get_collection_by_alias, search_items
from secretstorage.collection import (
Collection,
create_collection,
get_all_collections,
get_any_collection,
get_collection_by_alias,
get_default_collection,
search_items,
)
from secretstorage.exceptions import (
ItemNotFoundException,
LockedException,
PromptDismissedException,
SecretServiceNotAvailableException,
SecretStorageException,
)
from secretstorage.item import Item
from secretstorage.exceptions import SecretStorageException, \
SecretServiceNotAvailableException, LockedException, \
ItemNotFoundException, PromptDismissedException
from secretstorage.util import add_match_rules

__version_tuple__ = (3, 3, 3)
Expand Down
22 changes: 16 additions & 6 deletions secretstorage/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
collections.
"""

from typing import Optional
from collections.abc import Iterator
from typing import Optional

from jeepney.io.blocking import DBusConnection
from secretstorage.defines import SS_PREFIX, SS_PATH

from secretstorage.defines import SS_PATH, SS_PREFIX
from secretstorage.dhcrypto import Session
from secretstorage.exceptions import LockedException, ItemNotFoundException, \
PromptDismissedException
from secretstorage.exceptions import (
ItemNotFoundException,
LockedException,
PromptDismissedException,
)
from secretstorage.item import Item
from secretstorage.util import DBusAddressWrapper, exec_prompt, \
format_secret, open_session, unlock_objects
from secretstorage.util import (
DBusAddressWrapper,
exec_prompt,
format_secret,
open_session,
unlock_objects,
)

COLLECTION_IFACE = SS_PREFIX + 'Collection'
SERVICE_IFACE = SS_PREFIX + 'Service'
Expand Down
1 change: 0 additions & 1 deletion secretstorage/dhcrypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import hmac
import math
import os

from hashlib import sha256
from typing import Optional

Expand Down
15 changes: 11 additions & 4 deletions secretstorage/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@
:meth:`~secretstorage.collection.Collection.unlock` method."""

from typing import Optional

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from jeepney.io.blocking import DBusConnection

from secretstorage.defines import SS_PREFIX
from secretstorage.dhcrypto import Session
from secretstorage.exceptions import LockedException, PromptDismissedException
from secretstorage.util import DBusAddressWrapper, \
exec_prompt, open_session, format_secret, unlock_objects
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from secretstorage.util import (
DBusAddressWrapper,
exec_prompt,
format_secret,
open_session,
unlock_objects,
)

ITEM_IFACE = SS_PREFIX + 'Item'

Expand Down
36 changes: 27 additions & 9 deletions secretstorage/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,37 @@
import os
from typing import Any

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from jeepney import (
DBusAddress, DBusErrorResponse, MatchRule, Message, MessageType,
new_method_call, Properties,
DBusAddress,
DBusErrorResponse,
MatchRule,
Message,
MessageType,
Properties,
new_method_call,
)
from jeepney.io.blocking import DBusConnection
from secretstorage.defines import DBUS_UNKNOWN_METHOD, DBUS_NO_SUCH_OBJECT, \
DBUS_SERVICE_UNKNOWN, DBUS_NO_REPLY, DBUS_NOT_SUPPORTED, DBUS_EXEC_FAILED, \
DBUS_UNKNOWN_OBJECT, SS_PATH, SS_PREFIX, ALGORITHM_DH, ALGORITHM_PLAIN

from secretstorage.defines import (
ALGORITHM_DH,
ALGORITHM_PLAIN,
DBUS_EXEC_FAILED,
DBUS_NO_REPLY,
DBUS_NO_SUCH_OBJECT,
DBUS_NOT_SUPPORTED,
DBUS_SERVICE_UNKNOWN,
DBUS_UNKNOWN_METHOD,
DBUS_UNKNOWN_OBJECT,
SS_PATH,
SS_PREFIX,
)
from secretstorage.dhcrypto import Session, int_to_bytes
from secretstorage.exceptions import ItemNotFoundException, \
SecretServiceNotAvailableException
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from secretstorage.exceptions import (
ItemNotFoundException,
SecretServiceNotAvailableException,
)

BUS_NAME = 'org.freedesktop.secrets'
SERVICE_IFACE = SS_PREFIX + 'Service'
Expand Down
1 change: 1 addition & 0 deletions tests/cleanup_test_items.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

from contextlib import closing

import secretstorage

with closing(secretstorage.dbus_init()) as connection:
Expand Down
2 changes: 1 addition & 1 deletion tests/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python

import os.path
import sys
import subprocess
import sys
import unittest

tests_dir = os.path.dirname(__file__)
Expand Down
15 changes: 11 additions & 4 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
# This file tests the secretstorage.Collection class.

import unittest
from secretstorage import Collection, Item
from secretstorage import dbus_init, get_any_collection, get_all_collections
from secretstorage import create_collection, get_default_collection
from secretstorage.util import BUS_NAME

from secretstorage import (
Collection,
Item,
create_collection,
dbus_init,
get_all_collections,
get_any_collection,
get_default_collection,
)
from secretstorage.exceptions import ItemNotFoundException
from secretstorage.util import BUS_NAME


class CollectionTest(unittest.TestCase):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# This file tests using secretstorage.dbus_init() function
# together with contextlib.closing context manager.

from contextlib import closing
import unittest
from contextlib import closing

from secretstorage import check_service_availability, dbus_init
from secretstorage.collection import get_any_collection

Expand Down
1 change: 1 addition & 0 deletions tests/test_dhcrypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# This file tests the dhcrypto module.

import unittest

from secretstorage.dhcrypto import int_to_bytes


Expand Down
1 change: 1 addition & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Various exception tests

import unittest

import secretstorage
from secretstorage.exceptions import ItemNotFoundException

Expand Down
5 changes: 3 additions & 2 deletions tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

# This file tests the secretstorage.Collection class.

import unittest
import time
from secretstorage import dbus_init, search_items, get_any_collection
import unittest

from secretstorage import dbus_init, get_any_collection, search_items

ATTRIBUTES = {'application': 'secretstorage-test', 'attribute': 'qwerty'}
NEW_ATTRIBUTES = {'application': 'secretstorage-test',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unlocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import unittest

from secretstorage import dbus_init, Collection
from secretstorage.util import BUS_NAME
from secretstorage import Collection, dbus_init
from secretstorage.exceptions import LockedException
from secretstorage.util import BUS_NAME


@unittest.skipIf(BUS_NAME == "org.freedesktop.secrets",
Expand Down

0 comments on commit 7dc7258

Please sign in to comment.