未验证 提交 700398ec 编写于 作者: E Erwin Junge 提交者: GitHub

[mypy] annotate `ciphers` (#5569)

* [mypy] annotate `ciphers`

* Update ciphers/polybius.py

* Update polybius.py
Co-authored-by: NChristian Clauss <cclauss@me.com>
上级 e49d8e3a
...@@ -221,10 +221,13 @@ def decrypt_caesar_with_chi_squared( ...@@ -221,10 +221,13 @@ def decrypt_caesar_with_chi_squared(
# Get the most likely cipher by finding the cipher with the smallest chi squared # Get the most likely cipher by finding the cipher with the smallest chi squared
# statistic # statistic
most_likely_cipher: int = min( # type: ignore def chi_squared_statistic_values_sorting_key(key: int) -> tuple[float, str]:
chi_squared_statistic_values, # type: ignore return chi_squared_statistic_values[key]
key=chi_squared_statistic_values.get, # type: ignore
) # type: ignore 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) # Get all the data from the most likely cipher (key, decoded message)
( (
......
...@@ -45,8 +45,7 @@ class PolybiusCipher: ...@@ -45,8 +45,7 @@ class PolybiusCipher:
>>> PolybiusCipher().numbers_to_letter(1, 1) == "a" >>> PolybiusCipher().numbers_to_letter(1, 1) == "a"
True True
""" """
letter = self.SQUARE[index1 - 1, index2 - 1] return self.SQUARE[index1 - 1, index2 - 1]
return letter
def encode(self, message: str) -> str: def encode(self, message: str) -> str:
""" """
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册