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

ImportError: cannot import name 'Self' from 'typing_extensions' #2533

Closed
k9ert opened this issue Feb 11, 2023 · 6 comments
Closed

ImportError: cannot import name 'Self' from 'typing_extensions' #2533

k9ert opened this issue Feb 11, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@k9ert
Copy link

k9ert commented Feb 11, 2023

Traceback (most recent call last):
  File "/home/kim/.pyenv/versions/3.10.4/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/kim/.pyenv/versions/3.10.4/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/__main__.py", line 7, in <module>
    entry_point()
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/cli/cli_server.py", line 152, in server
    init_app(app, hwibridge=hwibridge)
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/server.py", line 166, in init_app
    specter.service_manager = ExtensionManager(
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/managers/service_manager/service_manager.py", line 56, in __init__
    class_list = get_classlist_of_type_clazz_from_modulelist(
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/util/reflection.py", line 94, in get_classlist_of_type_clazz_from_modulelist
    module = import_module(fq_module_name)
  File "/home/kim/.pyenv/versions/3.10.4/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specterext/devhelp/service.py", line 7, in <module>
    import strawberry
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/strawberry/__init__.py", line 1, in <module>
    from . import experimental, federation
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/strawberry/federation/__init__.py", line 1, in <module>
    from .argument import argument
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/strawberry/federation/argument.py", line 3, in <module>
    from strawberry.arguments import StrawberryArgumentAnnotation
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/strawberry/arguments.py", line 18, in <module>
    from strawberry.annotation import StrawberryAnnotation
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/strawberry/annotation.py", line 15, in <module>
    from typing_extensions import Annotated, Self, get_args, get_origin
ImportError: cannot import name 'Self' from 'typing_extensions' (/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/typing_extensions.py)

This is happening if i use typing_extensions==3.10.2 and it disappears after pip3 install typing_extensions==4.0.0. Now, i'd like to use 3.10.2 as i have a conflict otherwise:

  typing_extensions<5.0.0,>=3.7.4 (from strawberry-graphql==0.155.2->-r requirements.in (line 35))
  typing-extensions<4.0,>=3.7 (from hwi==2.1.1->-r requirements.in (line 11))

So i'd appreciate if you can either fix the issue or adjust the dependencies (in order to convince the other project to upgrade).

System Information

  • Operating system: Linux, python 3.10.4
  • Strawberry version (if applicable): 0.156.3
@k9ert k9ert added the bug Something isn't working label Feb 11, 2023
@patrick91
Copy link
Member

hi @k9ert, I'll see if we can put import Self inside an if TYPE_CHECKING

we are probably going to require typing extensions 4.1 soon due to #2227 so it might be worth asking those libraries not to do any upper level pinning for typing extensions

@k9ert
Copy link
Author

k9ert commented Feb 12, 2023

hi @k9ert, I'll see if we can put import Self inside an if TYPE_CHECKING

Thank you, very much appreciated. I've asked on the other project as well to get it up-to-date.

@patrick91
Copy link
Member

@k9ert can you list the other projects? I'll be happy to send a PR to them too (I feel like that's better than adding a workaround here, since it won't last long) :)

@k9ert
Copy link
Author

k9ert commented Feb 12, 2023

It's here: bitcoin-core/HWI#572
They are already thinking about the update.
And for the reference, this is for this project/PR: cryptoadvance/specter-desktop#2196

@patrick91
Copy link
Member

This should have been fixed in HWI now :) I'll close the issue!

@k9ert
Copy link
Author

k9ert commented Feb 27, 2023

The discussion is ongoing on there side and they have some point of not immediately removing the upper pin.

I'll see if we can put import Self inside an if TYPE_CHECKING

What about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants