-
Notifications
You must be signed in to change notification settings - Fork 272
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
with_metaclass: check existence of __prepare__
attribute before calling it
#252
Comments
Classes passed to `six.with_metaclass()` are expected to have a `__prepare__` method to pass `tox` checks, which is not defined by default in PY2 and not used. See also <benjaminp/six#252>.
Classes passed to `six.with_metaclass()` are expected to have a `__prepare__` method to pass `tox` checks, which is not defined by default in PY2 and not used. See also <benjaminp/six#252>.
Why is that a problem, though? Defining a |
Looks like Cython makes calls to |
Is there a Cython bug filed for that behavior? |
Here's the original report on Cython: cython/cython#1936 The issue was introduced in #178, already reported in #210, and an Open PR is out in #211. Unfortunately both the issue and PR have been open for 11 months, without much movement. @benjaminp, can we please either merge in #211, or go with a quick (and simpler) fix, which would be calling |
This is a problem because Python accepts any callable with the right signature as a metaclass, and this assumes that you are subclassing type (or something with a What I don't understand is why you're defining a metaclass in the decorator - why don't you just return
|
https://github.com/prettier/plugin-python/blob/04dc40a40501a13eaec5fcb4d5c99829a31d3ffc/vendor/python/six.py#L831
The
def with_metaclass()
implementation assumes that all meta classes have__prepare__
defined.The Python Reference says (https://docs.python.org/3/reference/datamodel.html#preparing-the-class-namespace):
Therefore, I think
six
should check existence of__prepare__
attribute before calling it, as__prepare__
is not defined ontype
in PY2.The text was updated successfully, but these errors were encountered: