cloudpathlib icon indicating copy to clipboard operation
cloudpathlib copied to clipboard

Module fails to import when Python is ran with -OO

Open jruere opened this issue 2 years ago • 1 comments

Since -OO removes docstrings, the module fails on import as shown in the following trace:

[...]
    from cloudpathlib import AnyPath, CloudPath
  File "/home/javier/.virtualenvs/WebsiteTopicClassifier/lib/python3.6/site-packages/cloudpathlib/__init__.py", line 3, in <module>
    from .anypath import AnyPath
  File "/home/javier/.virtualenvs/WebsiteTopicClassifier/lib/python3.6/site-packages/cloudpathlib/anypath.py", line 5, in <module>
    from .cloudpath import InvalidPrefixError, CloudPath
  File "/home/javier/.virtualenvs/WebsiteTopicClassifier/lib/python3.6/site-packages/cloudpathlib/cloudpath.py", line 136, in <module>
    class CloudPath(metaclass=CloudPathMeta):
  File "/home/javier/.virtualenvs/WebsiteTopicClassifier/lib/python3.6/site-packages/cloudpathlib/cloudpath.py", line 127, in __init__
    docstring = getattr(Path, attr).__doc__ + " _(Docstring copied from pathlib.Path)_"
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

jruere avatar Jul 07 '22 20:07 jruere

Thanks @jruere. We'd accept a PR that adds a condition to the ones that we check ahead of failure to also check that __doc__ is not None:

https://github.com/drivendataorg/cloudpathlib/blob/20b79c11974fce5b8e7b0fe292ba8d11b00dad49/cloudpathlib/cloudpath.py#L122-L126

pjbull avatar Jul 13 '22 01:07 pjbull

@jruere This is released now in version 0.10.0 on PyPI

pjbull avatar Aug 19 '22 01:08 pjbull

Much appreciated!

On Thu, 18 Aug 2022, 22:01 Peter Bull, @.***> wrote:

@jruere https://github.com/jruere This is released now in version 0.10.0 on PyPI

— Reply to this email directly, view it on GitHub https://github.com/drivendataorg/cloudpathlib/issues/238#issuecomment-1220125223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ5FRTKC4EVO2SFVNKODRDVZ3MHHANCNFSM526VVW6Q . You are receiving this because you were mentioned.Message ID: @.***>

jruere avatar Aug 19 '22 01:08 jruere