You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even though it does import from __future__ import annotations, it's not enough to patch the runtime interpreter: types still can't be ORed with the pipe syntax at runtime on Python less than 3.10.
Using Type(Union[list, dict]) instead does not fix the issue. Without future annotations in group/plugin.py:
$ python3.9Python 3.9.18 (main, Aug 26 2023, 14:52:42) [GCC 13.2.1 20230801] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from material.plugins.group import configTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/media/data/dev/copier-pdm/tests/tmp/__pypackages__/3.9/lib/material/plugins/group/config.py", line 31, in <module> class GroupConfig(Config): File "/media/data/dev/copier-pdm/tests/tmp/__pypackages__/3.9/lib/material/plugins/group/config.py", line 33, in GroupConfig plugins = Type(list | dict)TypeError: unsupported operand type(s) for |: 'type' and 'type'
With 3.10:
$ python3.10Python 3.10.13 (main, Aug 26 2023, 14:53:11) [GCC 13.2.1 20230801] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from material.plugins.group import config>>>
Thanks for reporting. Sorry, no exceptions. Providing a minimal reproduction should be straight forward and makes it faster for us to isolate and fix the problem. Please provide one, we're happy to look into it then.
I'm a bad user!
Done with 3.10 since the error happens at import time on 3.8/3.9 (like the mentioned issue) 🙂
pawamoy
changed the title
TypeError: unsupported operand type(s) for |: 'type' and 'type' (again)
TypeError: unsupported operand type(s) for |: 'type' and 'type' in group plugin
Oct 9, 2023
Context
mkdocs-material 9.4.4+insiders.4.42.1
Bug description
The group plugin has this code in
config.py
:Even though it does import
from __future__ import annotations
, it's not enough to patch the runtime interpreter: types still can't be ORed with the pipe syntax at runtime on Python less than 3.10.Using
Type(Union[list, dict])
instead does not fix the issue. Without future annotations ingroup/plugin.py
:With future annotations:
See discussion in MkDocs: mkdocs/mkdocs#3417
Related links
Reproduction
9.4.4+insiders.4.42.1-type-error-list-or-dict.zip
Steps to reproduce
With 3.9:
With 3.10:
Browser
No response
Before submitting
The text was updated successfully, but these errors were encountered: