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

Deprecate private functions #234

Merged
merged 2 commits into from
Nov 29, 2021

Conversation

samueljsb
Copy link
Contributor

@samueljsb samueljsb commented Oct 13, 2021

These functions (and the enum) are listed on the documentation but are not available from the root humanize package.

This change makes the private functions private by prepending their names with an underscore. In order to make this change backwards compatible, we provide aliases for the functions under the old names. These aliases will emit deprecation warnings if called. The aliases are removed in samueljsb#1.

This fixes #225.

@samueljsb samueljsb changed the title deprecate private functions Deprecate private functions Oct 13, 2021
@samueljsb samueljsb force-pushed the deprecate-private-functions branch 2 times, most recently from 89d9234 to 2d4f206 Compare October 13, 2021 22:47
@hugovk
Copy link
Collaborator

hugovk commented Nov 22, 2021

Any idea why the warning on _UnitMeta's __getattr__ is causing an error? It's just this one, the others are fine.

Would be nice to get this released soon, the Python 3.6 EOL is around the corner and dropping it will bring a major version bump (see #239), and would be a good time to bundle in removal of these deprecations too.

Thanks!

@hugovk hugovk mentioned this pull request Nov 25, 2021
4 tasks
@hugovk hugovk added the changelog: Deprecated For soon-to-be removed features label Nov 25, 2021
Prior to this change, the `Unit` enum and the `abs_timedelta` and
`date_and_delta` functions were listed as public functions in the
documentation but were not available from the root package:

    >>> import humanize
    >>> humanize.Unit
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: module 'humanize' has no attribute 'Unit'
    >>> humanize.abs_timedelta
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: module 'humanize' has no attribute 'abs_timedelta'

This change makes these members private.

In order to preserve backwards compatibility after this change, we
provide aliases for these members which emit deprecation warnings.
Prior to this change, the `Unit` enum and the `abs_timedelta` and
`date_and_delta` functions were listed as public functions in the
documentation but were not available from the root package:

    >>> import humanize
    >>> humanize.gettext
    Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
    AttributeError: module 'humanize' has no attribute 'gettext'
    >>> humanize.ngettext
    Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
    AttributeError: module 'humanize' has no attribute 'ngettext'

This change makes these members private.

In order to preserve backwards compatibility after this change, we
provide aliases for these members which emit deprecation warnings.
@samueljsb samueljsb force-pushed the deprecate-private-functions branch from 2d4f206 to 2fdcdb3 Compare November 29, 2021 16:58
@samueljsb
Copy link
Contributor Author

__getattr__ should have been __getattribute__! That's my bad for getting them mixed up.

The test run locally now, so I've pushed up the change.

@codecov-commenter
Copy link

Codecov Report

Merging #234 (2fdcdb3) into master (e926626) will decrease coverage by 2.67%.
The diff coverage is 76.62%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #234      +/-   ##
==========================================
- Coverage   99.68%   97.01%   -2.68%     
==========================================
  Files           9        9              
  Lines         635      670      +35     
==========================================
+ Hits          633      650      +17     
- Misses          2       20      +18     
Flag Coverage Δ
GHA_Ubuntu 95.82% <76.62%> (-2.61%) ⬇️
GHA_Windows 95.52% <76.62%> (-2.59%) ⬇️
GHA_macOS 95.82% <76.62%> (-2.61%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/humanize/i18n.py 83.82% <52.38%> (-14.26%) ⬇️
src/humanize/time.py 96.39% <83.67%> (-3.61%) ⬇️
src/humanize/number.py 99.13% <100.00%> (ø)
tests/test_time.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e926626...2fdcdb3. Read the comment docs.

@hugovk hugovk merged commit ab605ba into jmoiron:master Nov 29, 2021
@hugovk
Copy link
Collaborator

hugovk commented Nov 29, 2021

Thank you!

I'll release this later today, and then the next version will likely be a major bump (with #239) so feel free to create a removal PR whenever suits you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Deprecated For soon-to-be removed features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation shows private functions
3 participants