Update Python union and optional types to use `|` syntax
The current type syntax is not very user friendly, we should update all the types to use type1 | type2 instead of Union[type1, type2] and type | null instead of Optional[type] as soon as possible.
Another benefit of this is that we get less imports as the new type deceleration is native and don't rely on importing Union or Optional from typing.
- [ ] #4337
- [ ] Update types
Have you tried a helpful tool called pyupgrade? It can automatically rewrite Union and Option to new type notation with --py310-plus flag: https://github.com/asottile/pyupgrade/#pep-604-typing-rewrites.
Also, I can perform other refactorings like the conversion from str.format() to f-string. It looks like it always works perfectly but it can reduce manual work and error for refactoring.
Have you tried a helpful tool called
pyupgrade? It can automatically rewriteUnionandOptionto new type notation with--py310-plusflag: https://github.com/asottile/pyupgrade/#pep-604-typing-rewrites.Also, I can perform other refactorings like the conversion from
str.format()to f-string. It looks like it always works perfectly but it can reduce manual work and error for refactoring.
The problem isn't really the refactoring itself but I'm waiting for #4335 and #4337 before I do anything.
However that tool looks interesting so I'll keep it in mind when this is ready to be fixed.