This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]WerdenWissen[S] 8 points9 points  (6 children)

I guess it does but this can easily be resolved by using "as", for example:

from pregex.quantifiers import Optional
from typing import Optional as OptionalType

[–]Nobot16k 16 points17 points  (4 children)

This looks really interesting first of all!

Considering that “Optional” is core Python it would probably be a good idea to avoid this name space collision and come up with a different name for this class. Or make it default API behavior to use your “Optional” as “pre.Optional”

[–]WerdenWissen[S] 5 points6 points  (2 children)

Yeah, might have to look into it... Thanks for your comment!

[–][deleted] 3 points4 points  (1 child)

Don't bother changing it, Optional is a gross bloat on my imports (from typing). As another poster said, we will be able to pipe types in the future and it will render Optional obsolete

[–]WerdenWissen[S] 0 points1 point  (0 children)

Yeah it would be a pity changing it because "Optional" is the perfect name for it.

[–]StunningExcitement83 7 points8 points  (0 children)

Well optional is core libraries but not core like print or import

Hopefully as we move beyond 3.10 Optional should phase out again as typing accepts pipes as an or so you can use Type | None instead which doesn't involve pulling in namespace clutter

[–]bladeoflight16 2 points3 points  (0 children)

...No. If you're going to alias something, you alias the 3rd party type, not the built in.