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

Datetime.datetime throws TypeError: 'Datetime' object is not callable #1139

Closed
JonasMedu opened this issue Dec 16, 2021 · 5 comments
Closed
Assignees
Labels
bug Unexpected behaviour and bugs

Comments

@JonasMedu
Copy link

Bug report

As far as i can tell, the function "datetime" is not callable via the Schema creation.

According to the Api reference https://mimesis.name/api.html#mimesis.Datetime.datetime and the example in the getting started section i hoped i can create a schema as shown in Whats Wrong.

What's wrong

from mimesis.locales import Locale
from mimesis.schema import Field, Schema

_ = Field(locale=Locale.EN)
schema = Schema(schema=lambda: {
    "year": 2021,
    "uid": _("uuid"),
    "name": _("text.word"),
    "datetime": _("datetime"),
    "timestamp": _("timestamp", posix=False),
    "version": _("version", pre_release=True),
    "owner": _("text.word"),
})
list_of_dicts = schema.create(iterations=5)

Traceback:
TypeError: 'Datetime' object is not callable

How is that should be

A dictionary list_of_dicts should be created.

System information

Win10, Anaconda Python installation

@lk-geimfari
Copy link
Owner

@JonasMedu Can you try this, please: _("datetime.datetime")?

@lk-geimfari lk-geimfari added the bug Unexpected behaviour and bugs label Dec 16, 2021
@lk-geimfari lk-geimfari self-assigned this Dec 16, 2021
@JonasMedu
Copy link
Author

JonasMedu commented Dec 17, 2021

@lk-geimfari _("datetime.datetime") works nicely.
ref:

from mimesis.locales import Locale
from mimesis.schema import Field, Schema


_ = Field(Locale.EN)

schema = Schema(schema=lambda: {
    "year": 2021,
    "datetime": _("datetime.datetime", start=2021, end=2021),
    "name": _("text.word"),
    "company": _("company"),
    "target_value": _("integer_number", start=15200.0, end=1e10),
    "timestamp": _("timestamp", posix=False),
    "version": _("version", pre_release=True),
    "owner": _("stock_name"),
})
example = schema.create(iterations=10000)

edit: not quite sure if i can close topic :)

@lk-geimfari
Copy link
Owner

It is better to leave this issue open, because I did not fix the bug yet (since it is a bug). I'll close this issue on my own.

lk-geimfari added a commit that referenced this issue Dec 18, 2021
@lk-geimfari
Copy link
Owner

lk-geimfari commented Jan 7, 2022

@ngnpope I see that you've contributed a lot to mimesis lately, so maybe you'll find this bug interesting. I've fixed this issue in #1140, but my solution is too ugly (and too dumb) to merge it to master. Maybe you can solve this problem gracefully than I did.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
@lk-geimfari lk-geimfari reopened this Apr 16, 2022
@stale stale bot removed the stale label Apr 16, 2022
@lk-geimfari lk-geimfari reopened this Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour and bugs
Projects
None yet
Development

No branches or pull requests

2 participants