lk-geimfari / mimesis

Mimesis is a robust data generator for Python that can produce a wide range of fake data in multiple languages.
https://mimesis.name
MIT License
4.44k stars 336 forks source link

Address provider function country() does not apply locale or support allow_random param #1248

Closed willsthompson closed 2 years ago

willsthompson commented 2 years ago

Bug report

What's wrong

The API documentation for Address.country() indicates that it will "Get the country of the current locale", but the current local is not applied, and it instead always returns a random country:

>>> en = mimesis.Address(locale=Locale.EN)
>>> en.country()
'Nicaragua'
>>> en.country()
'Venezuela'
>>> en.country()
'Fiji'

Additionally, the function docs include the parameter allow_random. However, this has not been implemented:


>>> en.country(allow_random=False)
Traceback (most recent call last):
  File "/Users/willthompson/.pyenv/versions/3.9.11/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
TypeError: country() got an unexpected keyword argument 'allow_random'

How is that should be

Behavior should align with the documentation:

It looks like this was already implemented in #1114, but closed before merging. Could that be reopened and fixed up?

lk-geimfari commented 2 years ago

Absolutely. Can you, please, create a PR?

willsthompson commented 2 years ago

@lk-geimfari Sure, I'm happy to do it, but it would essentially be duplicating #1114. Would you rather reopen that one?