jazzband / imaplib2

Fork of Piers Lauder's imaplib2 library for Python.
https://imaplib2.readthedocs.io/
MIT License
33 stars 29 forks source link

add version() to access __version__ for the python 3 version #15

Closed piyueh closed 3 years ago

piyueh commented 3 years ago

Currently when __init__.py does from .imaplib2 import *, __version__ is not imported because it is not in __all__. However, offlineimap 3 requires this variable to under the top-level package name of imaplib2. See line 75 in offlineimap3/init.py: https://github.com/OfflineIMAP/offlineimap3/blob/1e7ef9e7e6952f5d29ef0f5c25fd062798de55f3/offlineimap/init.py#L75

~This PR adds __version__ to __all__.~

This PR adds a function version() to imaplib2.py3 to access __version__. The plan is to modify the offlineimap 3 to use this version() function.

thekix commented 3 years ago

Hello @piyueh

IMO the imaplib2 should include a method to retrieve the imaplib2 version. Something like imaplib2.version(). Accessing to the internal variable xxxxx IMO is not the right method. Then, we can use this function in offlineipam3.

OTOH, I think is better split your patch in two patches, one for the "style" (spaces, emtpy lines) and other for the version.

Best regards, kix

piyueh commented 3 years ago

Hi @thekix Yes I agree. I can probably do it later and push to this PR.

Ah, those removed spaces are automatically done by my editor. Not intentional...

piyueh commented 3 years ago

@thekix Now there's a version function that returns the version string. It can also return the version number as a tuple of (major, minor). I didn't make the change to the Python 2 version (the imaplib2.py file) because Python 2 has already reached EOL.