unpythonic
unpythonic copied to clipboard
Fix shadowed submodule names
Some constructs such as unpythonic.env.env and unpythonic.llist.llist have the same name as the submodule they live in. This hides the submodule from the dict of the top-level namespace of the unpythonic module. This behavior should be considered a bug.
To improve discoverability (e.g. groups of functionality; submodule top-level docstrings), the offending modules should be renamed to avoid becoming shadowed.
It's better to rename the modules than the symbols, since the symbols are certainly used by client code, but the submodule names necessarily aren't. It's not wrong to import directly from a submodule of unpythonic, if that feels more readable at the use site, but it's not mandatory, either, since the top-level __init__ imports all public symbols into the top-level unpythonic namespace. (This behavior is part of the public API, and is not going away.)
This is a breaking change, so we'll wait until the next major version before we do it.
CAUTION: Renaming the modules will break unpickling for instances that were pickled using the old version. [1] says that pickle can save and restore class instances transparently, however the class definition must be importable and live in the same module as when the object was stored. (emphasis mine)
This is also an issue because of The submodules are added to the package namespace trap. So if anything, anywhere, imports one of the submodules, the name in the top-level unpythonic namespace will reset to point to the submodule.
New names, list in progress:
unpythonic.it→unpythonic.itertools, in analogy with standarditertoolsunpythonic.fun→unpythonic.functools, similarlyunpythonic.llist→unpythonic.linkedlists
Maybe:
unpythonic.ec→unpythonic.escapesunpythonic.fup→unpythonic.fpupdate, in analogy withunpythonic.fploop