yhat / ggpy

ggplot port for python
http://yhat.github.io/ggpy/
BSD 2-Clause "Simplified" License
3.69k stars 573 forks source link

"metaclass conflict" error when using ggplot 0.6.8 with six 1.10.0+ #655

Open JoshRosen opened 5 years ago

JoshRosen commented 5 years ago

This ticket reports an issue which impacts ggpy 0.6.8, an older version of this library. I am reporting it in order to have a public reference to this issue.

If ggpy 0.6.8 is used with six 1.1.10 or newer then import ggplot will fail with a metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases error.

This is caused by the following unnecessary line of code:

https://github.com/yhat/ggpy/blob/v0.6.6/ggplot/themes/element_target.py#L122

The problem is that this code is using six's with_metaclass to be compatible with both Python 2 and 3 but it's also defining __metaclass__ (which is unnecessary). This pattern happened to work in earlier versions of six but this behavior broke in six 1.1.0 and started triggering errors.

Based on discussion at https://github.com/benjaminp/six/issues/210, the six maintainers don't seem to consider this a regression in six, so ggplot will need to be updated in order to be compatible with newer six versions.

This incompatibility can be resolved by simply deleting the __metaclass__ line I linked above.