Skip to content

humanize raises DeprecationWarning upon import #242

@jwodder

Description

@jwodder

As of humanize 3.13.0, simply doing import humanize causes a DeprecationWarning to be emitted about Unit. This is a problem for libraries that use humanize and whose tests are run with filterwarnings = error or equivalent in effect.

What did you do?

python3 -W error -c 'import humanize'

What did you expect to happen?

A lack of an error.

What actually happened?

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jwodder/.local/virtualenvwrapper/venvs/tmp-22afcaa7f55ab2/lib/python3.9/site-packages/humanize/__init__.py", line 17, in <module>
    from humanize.time import (
  File "/Users/jwodder/.local/virtualenvwrapper/venvs/tmp-22afcaa7f55ab2/lib/python3.9/site-packages/humanize/time.py", line 75, in <module>
    class Unit(Enum, metaclass=_UnitMeta):
  File "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/enum.py", line 215, in __new__
    enum_class._member_names_ = []               # names in definition order
  File "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/enum.py", line 470, in __setattr__
    member_map = cls.__dict__.get('_member_map_', {})
  File "/Users/jwodder/.local/virtualenvwrapper/venvs/tmp-22afcaa7f55ab2/lib/python3.9/site-packages/humanize/time.py", line 47, in __getattribute__
    warnings.warn(
DeprecationWarning: `Unit` has been deprecated. The enum is still available as the private member `_Unit`.

What versions are you using?

  • OS: macOS 11.6
  • Python: 3.9.9
  • Humanize: 3.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions