Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module fails to import when Python is ran with -OO #238

Closed
jruere opened this issue Jul 7, 2022 · 3 comments · Fixed by #249
Closed

Module fails to import when Python is ran with -OO #238

jruere opened this issue Jul 7, 2022 · 3 comments · Fixed by #249
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jruere
Copy link

jruere commented Jul 7, 2022

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'
@jayqi jayqi added the bug Something isn't working label Jul 7, 2022
@pjbull
Copy link
Member

pjbull commented Jul 13, 2022

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:

if (
not attr.startswith("_")
and hasattr(Path, attr)
and hasattr(getattr(Path, attr), "__doc__")
):

@pjbull
Copy link
Member

pjbull commented Aug 19, 2022

@jruere This is released now in version 0.10.0 on PyPI

@jruere
Copy link
Author

jruere commented Aug 19, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants