[PATCH v15 2/5] dts: replace the or operator in third party types

Luca Vizzarro Luca.Vizzarro at arm.com
Wed Aug 7 15:34:36 CEST 2024


Hi Juraj,

In the past, I have noticed this problem appear only on Python versions 
prior to 3.10. Before PEP 604[1] – introduced in Python 3.10 – the pipe 
operator was always used as an operator between objects instead of an 
alias for Union in the annotations. A quick test verifies this:

    Python 3.8.18 (default, Aug 25 2023, 13:20:30)
    [GCC 11.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
     >>> from collections import Counter
     >>> from typing import TypedDict
     >>> class t(TypedDict):
    ...     a: Counter | None
    ...
    Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 2, in t
    TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
     >>>

I have also attempted to build the docs removing this commit on my local 
setup (outside of the Poetry shell) and it appears to be working with no 
problems.

Best,
Luca

[1] https://peps.python.org/pep-0604/



More information about the dev mailing list