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.

Cannot subclass due to bad metaclass magic

See original GitHub issue

It’s impossible to inherit from the Faker class due to bad metaclass magic;

class Faker2(Faker):
    pass

  File "/vagrant/server/app/api/tests.py", line 44, in <module>
    class Faker2(Faker):
TypeError: Error when calling the metaclass bases
    first argument must be callable

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
foxxcommented, May 18, 2015

There are some more problems, again due to the way this library has been constructed.

The following is an instruction from the README, which fails to work;

>>> from faker.providers import BaseProvider
ImportError: No module named providers

There is far too much import abuse and magic going on, this project is a good idea but the implementation is very broken. Are there any plans to re-structure this in a pythonic way?

0reactions
github-actions[bot]commented, Jul 14, 2022

This issue was closed because it has been inactive for 14 days since being marked as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subclass avoiding parent's metaclass - python - Stack Overflow
What you can try is re-create the class using a different metaclass, which doesn't have unwanted behaviour. For example, you could use type...
Read more >
Problems once solved by a metaclass can be ... - Hacker News
Because metaclasses are classes, yes, classes whose instances are ... harmful: you have to start creating loads of explicit subclasses instead of one ......
Read more >
Understanding Python metaclasses | ionel's codelog
If you use a function as the metaclass then subclasses won't inherit your function metaclass, but the type of whatever that function returned....
Read more >
A Python Metaclass for "extra bad" errors in Google App Engine
By doing this, when the class ExtendedHandler is built (as an object), all of its attributes and all of its parent classes (or...
Read more >
Python Metaclasses - Real Python
“Metaclasses are deeper magic than 99% of users should ever worry about. ... Still, understanding Python metaclasses is worthwhile, because it leads to...
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