Skip to content
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

Closed
andreafrancia opened this issue Mar 28, 2024 · 10 comments · Fixed by #347
Closed

Don't force user to install old mock library #339

andreafrancia opened this issue Mar 28, 2024 · 10 comments · Fixed by #347

Comments

@andreafrancia
Copy link
Owner

          No problem.

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 :

Thank you for your contribution but I'm still using the old mock library
to keep trash-cli compatible with python 2.7


Reply to this email directly, view it on GitHub
#331 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB47WUGAGZUZYU7ZBKTPG6TY2PWA7AVCNFSM6AAAAABCDJAI5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRUHE2TQNBSG4
.
You are receiving this because you authored the thread.Message ID:
@.***>

Originally posted by @a-detiste in #331 (comment)

@andreafrancia
Copy link
Owner Author

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

@a-detiste
Copy link

a-detiste commented Mar 28, 2024 via email

@andreafrancia
Copy link
Owner Author

I don't remember, I think to make MyPy happy.

@andreafrancia
Copy link
Owner Author

MyPy happiness can be checked with

$ pip install -r requirements.txt -r requirements-dev.txt 
$ scripts/check-types

@a-detiste
Copy link

a-detiste commented Mar 28, 2024 via email

@andreafrancia
Copy link
Owner Author

I don't know any tool like that, I'm sorry :(

@eli-schwartz
Copy link
Contributor

I think the tool you want is probably https://github.com/ilevkivskyi/com2ann?

@eli-schwartz
Copy link
Contributor

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.

@andreafrancia
Copy link
Owner Author

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.

@a-detiste
Copy link

I think the tool you want is probably https://github.com/ilevkivskyi/com2ann?

Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants