Fixing types on the Python side.

14 views
Skip to first unread message

Mriswithe

unread,
Sep 3, 2025, 11:23:49 PM (8 days ago) Sep 3
to cython-users
Hello,

I was going through the getting started, the primes example. I noticed my IDE was complaining about the expected types. Example

    p: cython.int[1000]

Pycharm says it should be a int[Any] which is not really a thing, we want PyCharm to expect an array of ints. Are there known ("It is known khalesi") reasons why this shouldn't be fixed, or is this an ok direction for me to poke around and potentially fix?

My goal here is to make the experience for someone using an IDE smoother by having Pycharm and Cython agree what means what. Likely in this specific case I will implement a `__getitem__` method on the cython.int class in a pyi file. 

class NewInt(cython.int):
    def __getitem__(self, item) -> Iterable["NewInt"]:
        pass

Thank you for any input/corrections/references.

da-woods

unread,
Sep 7, 2025, 2:57:13 PM (4 days ago) Sep 7
to cython...@googlegroups.com
We're open to improvements here.

However, you may struggle - I think some of our pre-existing decisions on syntax (with memoryviews and arrays) just doesn't fit in with the increasingly formalized type-annotation syntax. I can't remember exactly why though (unfortunately).
--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/cd1e0bf8-1222-4614-8565-553b9b60dc40n%40googlegroups.com.


Mriswithe

unread,
Sep 7, 2025, 10:47:58 PM (4 days ago) Sep 7
to cython...@googlegroups.com
I will poke around and see what I can find then.

You received this message because you are subscribed to a topic in the Google Groups "cython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cython-users/t736YlkmEvA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cython-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cython-users/8524c9dd-1080-4aab-b026-57daedc61b8c%40d-woods.co.uk.
Reply all
Reply to author
Forward
0 new messages