Skip to content

TypeError: unsupported operand type(s) for |: 'sip.wrappertype' and 'type' #27

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

Closed
geraldo opened this issue Oct 16, 2024 · 5 comments · Fixed by #28
Closed

TypeError: unsupported operand type(s) for |: 'sip.wrappertype' and 'type' #27

geraldo opened this issue Oct 16, 2024 · 5 comments · Fixed by #28

Comments

@geraldo
Copy link

geraldo commented Oct 16, 2024

On QGIS 3.28.6 with Python 3.9.5 on Windows 10 the following error happens on installing the plugin:

TypeError: unsupported operand type(s) for |: 'sip.wrappertype' and 'type'
Traceback (most recent call last):
File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 423, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:\Users/havargas/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\a00_qpip_init
.py", line 2, in classFactory
from .plugin import Plugin
File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\Users/havargas/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\a00_qpip\plugin.py", line 20, in
class Plugin:
File "C:\Users/havargas/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\a00_qpip\plugin.py", line 134, in Plugin
def check_deps(self, additional_plugins=[]) -> MainDialog | bool:
TypeError: unsupported operand type(s) for |: 'sip.wrappertype' and 'type'

@m-kuhn
Copy link
Member

m-kuhn commented Oct 16, 2024

Are you able to validate if Union works for you?

from typing import Union

...

def check_deps(self, additional_plugins=[]) -> Union[MainDialog, bool]:

@geraldo
Copy link
Author

geraldo commented Oct 16, 2024

I´m not familiar with Union, but it seems to work on that machine. At least the following code runs without error and prints out x:

from typing import Union

def f(x: str) -> Union[str, None]:
    if x:
        return "x"

print(f("ok"))

@jmkerloch
Copy link
Contributor

I confirm this is fixing the issue on 3.28.1 with python 3.9.5 on Windows

jmkerloch added a commit to jmkerloch/qpip that referenced this issue Oct 24, 2024
@jmkerloch
Copy link
Contributor

I created a PR for the fix #28

@Danaozhong
Copy link

I got the same problem with the latest release and QGIS 3.34, any chance you could do a new release soon?

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

Successfully merging a pull request may close this issue.

4 participants