Skip to content

Commit c37bb95

Browse files
committed
Fixed annotations
1 parent e3678fd commit c37bb95

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Diff for: ciphers/a1z26.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
"""
88

99

10-
def encode(plain: str) -> list[int]:
10+
from typing import List
11+
12+
13+
def encode(plain: str) -> List[int]:
1114
"""
1215
>>> encode("myname")
1316
[13, 25, 14, 1, 13, 5]
1417
"""
1518
return [ord(elem) - 96 for elem in plain]
1619

1720

18-
def decode(encoded: list[int]) -> str:
21+
def decode(encoded: List[int]) -> str:
1922
"""
2023
>>> decode([13, 25, 14, 1, 13, 5])
2124
'myname'

Diff for: ciphers/trafid_cipher.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# https://en.wikipedia.org/wiki/Trifid_cipher
22

33

4-
def __encryptPart(messagePart: str, character2Number: dict[str, str]) -> str:
4+
from typing import Tuple, Dict
5+
6+
7+
def __encryptPart(messagePart: str, character2Number: Dict[str, str]) -> str:
58
one, two, three = "", "", ""
69
tmp = []
710

@@ -17,8 +20,8 @@ def __encryptPart(messagePart: str, character2Number: dict[str, str]) -> str:
1720

1821

1922
def __decryptPart(
20-
messagePart: str, character2Number: dict[str, str]
21-
) -> tuple[str, str, str]:
23+
messagePart: str, character2Number: Dict[str, str]
24+
) -> Tuple[str, str, str]:
2225
tmp, thisPart = "", ""
2326
result = []
2427

@@ -36,7 +39,7 @@ def __decryptPart(
3639

3740
def __prepare(
3841
message: str, alphabet: str
39-
) -> tuple[str, str, dict[str, str], dict[str, str]]:
42+
) -> Tuple[str, str, Dict[str, str], Dict[str, str]]:
4043
# Validate message and alphabet, set to upper and remove spaces
4144
alphabet = alphabet.replace(" ", "").upper()
4245
message = message.replace(" ", "").upper()

Diff for: ciphers/xor_cipher.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"""
1919

2020

21+
from typing import List
22+
23+
2124
class XORCipher:
2225
def __init__(self, key: int = 0):
2326
"""
@@ -28,7 +31,7 @@ def __init__(self, key: int = 0):
2831
# private field
2932
self.__key = key
3033

31-
def encrypt(self, content: str, key: int) -> list[str]:
34+
def encrypt(self, content: str, key: int) -> List[str]:
3235
"""
3336
input: 'content' of type string and 'key' of type int
3437
output: encrypted string 'content' as a list of chars
@@ -53,7 +56,7 @@ def encrypt(self, content: str, key: int) -> list[str]:
5356

5457
return ans
5558

56-
def decrypt(self, content: str, key: int) -> list[str]:
59+
def decrypt(self, content: str, key: int) -> List[str]:
5760
"""
5861
input: 'content' of type list and 'key' of type int
5962
output: decrypted string 'content' as a list of chars

0 commit comments

Comments
 (0)