-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't force user to install old mock library #339
Comments
Yes, but this code should be put in single place. from trashcli.compat import Protocol If you want can make it works also for 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
<#339 (comment)>,
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? |
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. |
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 #331 (comment)
The text was updated successfully, but these errors were encountered: