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.

Implement PEP-487: customisation of class creation

See original GitHub issue
class ABC:
    def __init_subclass__(cls):
        print(cls)


class SubClass(ABC):
    pass

If you run this with python directly, it gives:

<class '__main__.SubClass'>

But after I compile it with cython, it gives:

TypeError                                 Traceback (most recent call last)
<ipython-input-1-a0954f22e2a4> in <module>
----> 1 import test

test.pyx in init test()

TypeError: __init_subclass__() takes exactly one argument (0 given)

How to solve it?

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
rayzchencommented, Jul 4, 2021

I don’t really know how I fixed it but its fixed now…

0reactions
rayzchencommented, Jul 4, 2021

I don’t know what is going on now, but the error is still there. Here is the build: https://ci.appveyor.com/project/rayzchen/pyunity/build/job/i011xbqufc0tj03o

Lines 39-533 are the main focus. Line 39 installs cython 3.0a8, line 57 creates the cython files (using cythonize -3 -q file.py) and the rest is just creating the bdist. However, when I install the wheel provided (tested on both python 3.9 win32 and win_amd64) and run an example, the error happens when subclassing from pyunity.Behaviour, which defines __init_subclass__. But for some reason, it works randomly on another computer that I have open. I really am too confused right now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 487 – Simpler customisation of class creation
Currently, customising class creation requires the use of a custom metaclass. This custom metaclass then persists for the entire lifecycle of the class, ......
Read more >
[Python-Dev] PEP487: Simpler customization of class creation
While implementing PEP 487 I realized that there is and oddity in the type base class: type.__init__ forbids to use keyword arguments, even...
Read more >
PEP 487: Customizing Class Creation - Real-world examples
I'm fairly intermediate with Python (been using it about 2ish years now for mainly data-related tasks). Ever since the introduction of PEP ......
Read more >
Re: [Python-Dev] PEP487: Simpler customization of class creation ...
In any case I find this PEP great. If we can implement a library like traitlets only using these new hooks without a...
Read more >
pep487 - PyPI
PEP487 - Simpler customisation of class creation. ... from pep487 import PEP487Object >>> class FooBase(PEP487Object): ... foos = set() ...
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