question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lk-geimfaricommented, Dec 17, 2021

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.

1reaction
JonasMeducommented, 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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: 'datetime.datetime' object is not callable
This is because you are having a variable called date that is shadowing imported datetime.date . Use a different variable name. Demo:
Read more >
TypeError: 'datetime.datetime' object is not callable | bobbyhadz
The Python "TypeError: 'datetime.datetime' object is not callable" occurs when we override a built-in class or method from the datetime module.
Read more >
TypeError: 'datetime.datetime' object is not callable when I ...
Coding example for the question TypeError: 'datetime.datetime' object is not callable when I generate LazyDatetime-django.
Read more >
datetime.date' object is not subscriptable - You.com - You.com
TypeError : 'datetime.datetime' object is not subscriptable The error occurs because today is a datetime.datetimeobject. We are trying to access values in the ......
Read more >
TypeError: 'datetime.datetime' object is not callable - Groups.io
TypeError : 'datetime.datetime' object is not callable. Any idea how I can reference the 'time' field without an error?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found