python-humanize / humanize

Python humanize functions
https://humanize.readthedocs.io
MIT License
458 stars 61 forks source link

DeprecationWarning: Plural value must be an integer, got float #106

Closed mtelka closed 11 months ago

mtelka commented 1 year ago

What did you do?

I ran tests.

What did you expect to happen?

Tests pass without warnings.

What actually happened?

The following warning was reported:

=============================== warnings summary ===============================
tests/test_i18n.py::test_i18n
  $(@D)/src/humanize/i18n.py:133: DeprecationWarning: Plural value must be an integer, got float
    return get_translation().ngettext(message, plural, num)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

What versions are you using?

hugovk commented 1 year ago

Thanks for the report, a PR is welcome!

dansarpong commented 11 months ago

Hello, I would like to work on this issue. If you don't mind, could you tell me how to run the test and achieve the same results so that I can my hands on fixing it?

Thanks!

hugovk commented 11 months ago

Sure, something like this. Assuming you've already forked and cloned, then:

# First do an editable install
pip install -e ".[tests]"

# Generate translations
scripts/generate-translation-binaries.sh
$ # Then run tests
$ pytest tests/test_i18n.py
================================================================================================ test session starts ================================================================================================
platform darwin -- Python 3.11.5, pytest-7.4.2, pluggy-1.3.0
Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type>
rootdir: /Users/hugo/github/humanize
configfile: pyproject.toml
plugins: random-order-1.1.0, anyio-4.0.0, asyncio-0.21.0, flaky-3.7.0, timeout-2.1.0, cov-4.1.0, respx-0.20.1, mock-3.11.1, xdist-3.3.1, hypothesis-6.75.2, lazy-fixture-0.6.3, aiohttp-1.0.4
asyncio: mode=Mode.STRICT
collected 28 items

tests/test_i18n.py ............................                                                                                                                                                               [100%]

================================================================================================= warnings summary ==================================================================================================
tests/test_i18n.py::test_i18n
  /Users/hugo/github/humanize/src/humanize/i18n.py:126: DeprecationWarning: Plural value must be an integer, got float
    return get_translation().ngettext(message, plural, num)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================================== 28 passed, 1 warning in 0.04s ===========================================================================================
dansarpong commented 11 months ago

Alright, I believe i can handle this. Could you assign it to me?

Ps: Could you also kindly add the hacktoberfest label too? Thanks!

hugovk commented 11 months ago

We don't normally assign issues but go ahead. Also the repo already has the Hacktoberfest topic, so we don't need to label it. Thanks!

dansarpong commented 11 months ago

Apologies as this is my first PR, but how do I run the checks required? I didn't find anything related to that from the Contributing docs

hugovk commented 11 months ago

For new contributors, I need to click a button to approve the CI run. It's a GitHub default to prevent cryptocoin mining. I've now clicked it! ⏯️

dansarpong commented 11 months ago

Hello @hugovk, is there any guideline I may have overlooked? I have refixed the code and passed the tests, but it hasn't been merged yet so I was wondering if there is something I might have missed. Apologies if I'm being such a bother at the moment.

hugovk commented 11 months ago

Hi there, everything looks in place, I just need to find some time to give it a review. Don't worry, I expect we can get it all sorted during October :) Thanks!

dansarpong commented 11 months ago

Alright then. Thank you :)