Open andreafrancia opened 3 months ago
Yes, but this code should be put in single place. We already have code like this:
from trashcli.compat import Protocol
If you want can make it works also for Mock
and call
, something like
from trashcli.compat import Mock
from trashcli.compat import call
Thank you
What's the purpose of the wrapping ?
def protocol():
(wrapped code)
Protocol = protocol()
del protocol
I think this should do the same: (I ve seen this construct in many other projects)
__all__ = ['Protocol']
try:
from typing import Protocol
except ImportError as e:
from typing_extensions import Protocol
Le jeu. 28 mars 2024 à 14:30, Andrea Francia @.***> a écrit :
Yes, but this code should be put in single place. We already have code like this:
from trashcli.compat import Protocol
If you want can make it works also for Mock and call, something like
from trashcli.compat import Mockfrom trashcli.compat import call
Thank you
— Reply to this email directly, view it on GitHub https://github.com/andreafrancia/trash-cli/issues/339#issuecomment-2025192221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB47WUE3E3BGYXNSZE6QNTTY2QENBAVCNFSM6AAAAABFMZKHV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRVGE4TEMRSGE . You are receiving this because you were mentioned.Message ID: @.***>
I don't remember, I think to make MyPy happy.
MyPy happiness can be checked with
$ pip install -r requirements.txt -r requirements-dev.txt
$ scripts/check-types
ok I'll check ...: it's unrelated but if you know a tool to automatically rewrite Python2-style annotations in Python3 style that would be welcome (I have to translate a project with +>1000 annotated functions)
Le jeu. 28 mars 2024 à 14:45, Andrea Francia @.***> a écrit :
MyPy happiness can be checked with
$ pip install -r requirements.txt -r requirements-dev.txt $ scripts/check-types
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
I don't know any tool like that, I'm sorry :(
I think the tool you want is probably https://github.com/ilevkivskyi/com2ann?
Yes, but this code should be put in single place. We already have code like this:
from trashcli.compat import Protocol
I would recommend not doing it like this, because it's problematic and prevents automatic rewriting. And the try/except is very hard for type checkers and linters to understand. Instead it is recommended to do an if/else on sys.version_info.
Yes, but this code should be put in single place. We already have code like this:
from trashcli.compat import Protocol
I would recommend not doing it like this, because it's problematic and prevents automatic rewriting. And the try/except is very hard for type checkers and linters to understand. Instead it is recommended to do an if/else on sys.version_info.
Please provide a different solution if you have one.
I think the tool you want is probably https://github.com/ilevkivskyi/com2ann?
Thank you so much
Would you accept to hybridize mock usage ?
Like this:
try: from unittest import mock except ImportError: import mock
We are slowly trying to remove mock,nose,unittest2,future etc... from Debian; so what is done is done :-)
Le jeu. 28 mars 2024 à 12:27, Andrea Francia @.***> a écrit :
Originally posted by @a-detiste in https://github.com/andreafrancia/trash-cli/issues/331#issuecomment-2025114990