[mypy] annotate ciphers (#5569)

* [mypy] annotate `ciphers`

* Update ciphers/polybius.py

* Update polybius.py

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Erwin Junge 2021-10-26 12:35:21 +02:00 committed by GitHub
parent e49d8e3af4
commit 700398ec06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -221,10 +221,13 @@ def decrypt_caesar_with_chi_squared(
# Get the most likely cipher by finding the cipher with the smallest chi squared
# statistic
most_likely_cipher: int = min( # type: ignore
chi_squared_statistic_values, # type: ignore
key=chi_squared_statistic_values.get, # type: ignore
) # type: ignore
def chi_squared_statistic_values_sorting_key(key: int) -> tuple[float, str]:
return chi_squared_statistic_values[key]
most_likely_cipher: int = min(
chi_squared_statistic_values,
key=chi_squared_statistic_values_sorting_key,
)
# Get all the data from the most likely cipher (key, decoded message)
(

View File

@ -45,8 +45,7 @@ class PolybiusCipher:
>>> PolybiusCipher().numbers_to_letter(1, 1) == "a"
True
"""
letter = self.SQUARE[index1 - 1, index2 - 1]
return letter
return self.SQUARE[index1 - 1, index2 - 1]
def encode(self, message: str) -> str:
"""