manoss96/pregex

Change naming of "Optional" to not conflict with Python standard typing library

AlexisGoodfellow opened this issue · 1 comments

Right now, from pregex.quantifiers import Optional will compete/conflict with the native python typing module's from typing import Optional.

Since the python standard lib is used pretty ubiquitously in modern projects, it probably makes more sense to change the naming of Optional here to something else.

Hey there! I get what you are saying, though I believe that if someone explicitly writes from pregex.quantifiers import Optional then they are aware of what is being imported, and thus they can resolve any conflicts on their own, for example by importing the class with a different name: from pregex.quantifiers import Optional as Opt. In any case, there is no way for a pregex class to be imported without you being aware of it, as from pregex import * will import every module using a short alias. In fact, due to pregex having a relatively large number of modules as well as due to the fact that the module to which each class belongs reveals information about how each class can be used, this is the recommended way to import from pregex. You can read more about it in the documentation.