Mimesis: Issue with __str__ of providers without locale

Created on 3 Jun 2017  路  9Comments  路  Source: lk-geimfari/mimesis

So, now if we try this:

from elizabeth import Numbers

n = Numbers()
print(n))

We will get this:

Traceback (most recent call last):
  File "/home/lk/Development/open_source/elizabeth/app.py", line 5, in <module>
    print(Numbers())
  File "/home/lk/Development/open_source/elizabeth/elizabeth/core/providers.py", line 79, in __str__
    locale_info(self.locale)
  File "/home/lk/Development/open_source/elizabeth/elizabeth/utils.py", line 30, in locale_info
    locale = locale.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Because not all providers need locale.

bug

Most helpful comment

@Valerievich Magic. I do not remember fixing this.

All 9 comments

@sobolevn What do you propose to do? Maybe just don't inherit the BaseProvider() when providers does not need locale?

Maybe it is good idea to refactor locale_info() not to break on None values?
I am strongly sure that all providers must inherit from some base class.

@sobolevn Agree. I will refactor it.

@Valerievich And this.

This issue is no longer relevant I think, right?

@Valerievich Actually is relevant. Check this out, please.

I've built mimesis from master and got this:
```(elizabeth_env) Ruslans-MacBook-Pro:mimesis ruslanv.$ python3
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from mimesis import Numbers
n = Numbers()
print(n)
Numbers:en:English
```

@Valerievich Magic. I do not remember fixing this.

@Valerievich Anyway, it's cool.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dumprop picture dumprop  路  6Comments

lk-geimfari picture lk-geimfari  路  6Comments

lk-geimfari picture lk-geimfari  路  4Comments

sobolevn picture sobolevn  路  6Comments

faheel picture faheel  路  4Comments