Skip to content

Commit 4cc4ce8

Browse files
committed
Replace Optional[T] with T | None
1 parent 50d65b0 commit 4cc4ce8

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

secretstorage/collection.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"""
1818

1919
from collections.abc import Iterator
20-
from typing import Optional
2120

2221
from jeepney.io.blocking import DBusConnection
2322

@@ -48,7 +47,7 @@ class Collection:
4847

4948
def __init__(self, connection: DBusConnection,
5049
collection_path: str = DEFAULT_COLLECTION,
51-
session: Optional[Session] = None) -> None:
50+
session: Session | None = None) -> None:
5251
self.connection = connection
5352
self.session = session
5453
self.collection_path = collection_path
@@ -154,7 +153,7 @@ def __repr__(self) -> str:
154153

155154

156155
def create_collection(connection: DBusConnection, label: str, alias: str = '',
157-
session: Optional[Session] = None) -> Collection:
156+
session: Session | None = None) -> Collection:
158157
"""Creates a new :class:`Collection` with the given `label` and `alias`
159158
and returns it. This action requires prompting.
160159
@@ -185,7 +184,7 @@ def get_all_collections(connection: DBusConnection) -> Iterator[Collection]:
185184

186185

187186
def get_default_collection(connection: DBusConnection,
188-
session: Optional[Session] = None) -> Collection:
187+
session: Session | None = None) -> Collection:
189188
"""Returns the default collection. If it doesn't exist,
190189
creates it."""
191190
try:

secretstorage/dhcrypto.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import math
1212
import os
1313
from hashlib import sha256
14-
from typing import Optional
1514

1615
# A standard 1024 bits (128 bytes) prime number for use in Diffie-Hellman exchange
1716
DH_PRIME_1024_BYTES = (
@@ -37,8 +36,8 @@ def int_to_bytes(number: int) -> bytes:
3736

3837
class Session:
3938
def __init__(self) -> None:
40-
self.object_path: Optional[str] = None
41-
self.aes_key: Optional[bytes] = None
39+
self.object_path: str | None = None
40+
self.aes_key: bytes | None = None
4241
self.encrypted = True
4342
# 128-bytes-long strong random number
4443
self.my_private_key = int.from_bytes(os.urandom(0x80), 'big')

secretstorage/item.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
the item is unlocked. The collection can be unlocked using collection's
1010
:meth:`~secretstorage.collection.Collection.unlock` method."""
1111

12-
from typing import Optional
13-
1412
from cryptography.hazmat.backends import default_backend
1513
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
1614
from jeepney.io.blocking import DBusConnection
@@ -33,7 +31,7 @@ class Item:
3331
"""Represents a secret item."""
3432

3533
def __init__(self, connection: DBusConnection,
36-
item_path: str, session: Optional[Session] = None) -> None:
34+
item_path: str, session: Session | None = None) -> None:
3735
self.item_path = item_path
3836
self._item = DBusAddressWrapper(item_path, ITEM_IFACE, connection)
3937
self._item.get_property('Label')

0 commit comments

Comments
 (0)