TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' #4699
-
What happened?When running
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' What should've happened instead?migrations should be run properly Additional detailsI think this error is because its expecting python 3.11 but i wanted to use python 3.9 and it does not support use of | symbol Error trace
$ cookiecutter https://github.com/cookiecutter/cookiecutter-django project_name [Project Name]: ... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
What's the python version you use? |
Beta Was this translation helpful? Give feedback.
-
@sandeepeecs From the logs and your comment, you are using python3.9. However the current version of cookiecutter-django expects python3.11. To fix the problem on the Observing this will not prevent/fix if the same error from happening due to some Python dependency making use of functionality that only exists in Python3.10+. Ideally, it would be best if you used Python3.11 or higher. The |
Beta Was this translation helpful? Give feedback.
@sandeepeecs From the logs and your comment, you are using python3.9. However the current version of cookiecutter-django expects python3.11.
To fix the problem on the
users/managers.py
, simply addfrom __future__ import annotations
at the top (first line) of theusers/managers.py
file and any other python file that makes use of the|
operator on type hints.Observing this will not prevent/fix if the same error from happening due to some Python dependency making use of functionality that only exists in Python3.10+. Ideally, it would be best if you used Python3.11 or higher.
The
|
operator for type hint was included in Python3.10+ by PEP 604