Conversation
…sts for it; Replace `user` and `shared_user` correspond properties implementations on a new functinos.
…rnames.py` implementation; Note: `full_name` and `effective_name` can not be easily replaced in the such way
Closed
Thanks for the updates! I had just a very quick look so far
- I'm not sure if I have used overloads correctly, as warnings are still present.
I don't see anything wrong at first glance, but haven't seen the mypy warnings (pre-commit truncated the output). Looking up other code, have a look at
| Tele_co = TypeVar("Tele_co", bound=TelegramObject, covariant=True) | |
| TeleCrypto_co = TypeVar("TeleCrypto_co", bound="HasDecryptMethod", covariant=True) | |
| if TYPE_CHECKING: | |
| @type_check_only | |
| class HasDecryptMethod(Protocol): | |
| __slots__ = () | |
| @classmethod | |
| def de_json_decrypted( | |
| cls: type[TeleCrypto_co], | |
| data: JSONDict, | |
| bot: Optional["Bot"], | |
| credentials: list["FileCredentials"], | |
| ) -> TeleCrypto_co: ... | |
| @classmethod | |
| def de_list_decrypted( | |
| cls: type[TeleCrypto_co], | |
| data: list[JSONDict], | |
| bot: Optional["Bot"], | |
| credentials: list["FileCredentials"], | |
| ) -> tuple[TeleCrypto_co, ...]: ... |
for how Protocol and typevar are used there. maybe that helps.
- There is a failed slots test for the class.
in the above code section the if TYPE_CHECKING ensures that the class is not defined at test runtime. this would get the test passing.
- Is it necessary to test the properties of the User class, or utils.usernames is sufficient to test ?
I'd say testing the properties of the User(/Chat/SharedUser) class is enough and explicitly testing _utils.usernames is not required :)
Please also install the pre-commit hooks
| # You should have received a copy of the GNU Lesser Public License | ||
| # along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
| """Shared properties to extract username, first_name, last_name values if filled.""" | ||
| from __future__ import annotations |
| unlike the `Chat` and `Shared`, were they are optional. | ||
| The `last_name` is always optional. | ||
| """ | ||
| last_name: str | None |
Merged
Labels
None yet