criccomini / proto-schema-parser

A Pure Python Protobuf Parser
MIT License
38 stars 20 forks source link

AST union types should be compatible with python <3.10 #10

Closed usefulalgorithm closed 10 months ago

usefulalgorithm commented 10 months ago

For older versions of Python it is not allowed to write union types like

Foo = Bar | Baz

This would not work even if from __future__ import annotations is in the code.

To make it compatible with Python < 3.10, it has to be:

from typing import Union
Foo = Union[Bar, Baz]

Note that with from __future__ import annotations it is OK to have the following in Python <3.10:

def foo(
    bar: str | int,
):

Thanks!

criccomini commented 10 months ago

Good catch! Thanks. I've merged and will publish a PyPi shortly.

criccomini commented 10 months ago

Published 0.4.0!

https://pypi.org/project/proto-schema-parser/#history