Repository: python-telegram-bot/python-telegram-bot

Issue:
[Type Hinting] `EncryptedCredentials.decrypted_secret` is not properly annotated
### Steps to Reproduce

1. Create a `my_test.py` such as:

```python
from telegram import EncryptedCredentials
from tests.auxil.pytest_classes import make_bot

bot = make_bot(token="token")

my = {
    "credentials": {
        "hash": "qB4hz2LMcXYhglwz6EvXMMyI3PURisWLXl/iCmCXcSk=",
        "secret": "O6x3X2JrLO1lUIhw48os1gaenDuZLhesoZMKXehZwtM3vsxOdtxHKWQyLNwtbyy4snYpARXDwf8f1QHNmQ/M1PwBQvk1ozrZBXb4a6k/iYj+P4v8Xw2M++CRHqZv0LaxFtyHOXnNYZ6dXpNeF0ZvYYTmm0FsYvK+/3/F6VDB3Oe6xWlXFLwaCCP/jA9i2+dKp6iq8NLOo4VnxenPKWWYz20RZ50MdAbS3UR+NCx4AHM2P5DEGrHNW0tMXJ+FG3jpVrit5BuCbB/eRgKxNGRWNxEGV5hun5MChdxKCEHCimnUA97h7MZdoTgYxkrfvDSZ/V89BnFXLdr87t/NLvVE0Q==",
        "data": "MjHCHQT277BgJMxq5PfkPUl9p9h/5GbWtR0lcEi9MvtmQ9ONW8DZ3OmddaaVDdEHwh6Lfcr/0mxyMKhttm9QyACA1+oGBdw/KHRzLKS4a0P+rMyCcgctO6Q/+P9o6xs66hPFJAsN+sOUU4d431zaQN/RuHYuGM2s14A1K4YNRvNlp5/0JiS7RrV6SH6LC/97CvgGUnBOhLISmJXiMqwyVgg+wfS5SnOy2hQ5Zt/XdzxFyuehE3W4mHyY5W09I+MB/IafM4HcEvaqfFkWPmXNTkgBk9C2EJU9Lqc0PLmrXZn4LKeHVjuY7iloes/JecYKPMWmNjXwZQg/duIXvWL5icUaNrfjEcT5oljwZsrAc6NyyZwIp4w/+cb98jFwFAJ5uF81lRkZbeC3iw84mdpSVVYEzJSWSkSRs6JydfRCOYki0BNX9RnjgGqPYT+hNtUpEix2vHvJTIyvceflLF5vu+ol/axusirRiBVgNjKMfhs+x5bwBj5n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xe8kMP1Wru8GrzF5z+pbfNp1tB80NqOrqJUbRnPB2I9Fb47ab76L8RBu2MROUNGcKJ62imQtfPH2I0f8zpbqqTZQwr3AmZ+PS9df2hHp2dYR9gFpMyR9u+bJ7HbpiKbYhh7mEFYeB/pQHsQRqM2OU5Bxk8XzxrwsdnzYO6tVcn8xr3Q4P9kZNXA6X5H0vJPpzClWoCPEr3ZGGWGl5DOhfsAmmst47vdAA1Cbl5k3pUW7/T3LWnMNwRnP8OdDOnsm06/v1nxIDjH08YlzLj4GTeXphSnsXSRNKFmz+M7vsOZPhWB8Y/WQmpJpOIj6IRstLxJk0h47TfYC7/RHBr4y7HQ8MLHODoPz/FM+nZtm2MMpB+u0qFNBvZG+Tjvlia7ZhX0n0OtivLWhnqygx3jZX7Ffwt5Es03wDP39ru4IccVZ9Jly/YUriHZURS6oDGycH3+DKUn5gRAxgOyjAwxGRqJh/YKfPt14d4iur0H3VUuLwFCbwj5hSvHVIv5cNapitgINU+0qzIlhyeE0HfRKstO7nOQ9A+nclqbOikYgurYIe0z70WZyJ3qSiHbOMMqQqcoKOJ6M9v2hDdJo9MDQ13dF6bl4+BfX4mcF0m7nVUBkzCRiSOQWWFUMgLX7CxSdmotT+eawKLjrCpSPmq9sicWyrFtVlq/NYLDGhT0jUUau6Mb5ksT+/OBVeMzqoezUcly29L1/gaeWAc8zOApVEjAMT48U63NXK5o8GrANeqqAt3TB36S5yeIjMf194nXAAzsJZ+s/tXprLn2M5mA1Iag4RbVPTarEsMp10JYag==",
    }
}

a = EncryptedCredentials(my["credentials"]["data"], my["credentials"]["hash"], my["credentials"]["secret"])
a.set_bot(bot)
print(type(a.decrypted_secret))
```

2. Run

```
<class 'bytes'>
```

But, it is wrongly annotated like this:

https://github.com/python-telegram-bot/python-telegram-bot/blob/3ec7bb819ca7a316e4f02fd4f4e6b1759eaefb7a/telegram/_passport/credentials.py#L162

### Expected behaviour

```python
def decrypted_secret(self) -> bytes:
```

### Actual behaviour

```python
def decrypted_secret(self) -> str:
```

### Operating System

Ubuntu 22.04

### Version of Python, python-telegram-bot & dependencies

```shell
python-telegram-bot 21.0.1 (v21.0.1-8-g3ec7bb81)
Bot API 7.1
Python 3.9.18 (main, Feb 13 2024, 14:37:08)  [GCC 9.4.0]
```


### Relevant log output

_No response_

### Additional Context

_No response_


Discussion:
If this issue is accepted, I think this annotation should be changed from str to bytes as well:

https://github.com/python-telegram-bot/python-telegram-bot/blob/3ec7bb819ca7a316e4f02fd4f4e6b1759eaefb7a/telegram/_passport/credentials.py#L156
Hi. Your observation looks valid to me on a quick look into the code. TBH, passport related functionality is used so rarely that I don't have a good overview over that part of the code … You're very welcome to send a PR!

Resolving patch:
diff --git a/telegram/_passport/credentials.py b/telegram/_passport/credentials.py
--- a/telegram/_passport/credentials.py
+++ b/telegram/_passport/credentials.py
@@ -153,15 +153,15 @@ def __init__(
 
         self._id_attrs = (self.data, self.hash, self.secret)
 
-        self._decrypted_secret: Optional[str] = None
+        self._decrypted_secret: Optional[bytes] = None
         self._decrypted_data: Optional[Credentials] = None
 
         self._freeze()
 
     @property
-    def decrypted_secret(self) -> str:
+    def decrypted_secret(self) -> bytes:
         """
-        :obj:`str`: Lazily decrypt and return secret.
+        :obj:`bytes`: Lazily decrypt and return secret.
 
         Raises:
             telegram.error.PassportDecryptionError: Decryption failed. Usually due to bad


Test patch: