-  
-   Notifications  You must be signed in to change notification settings 
- Fork 3k
Description
Bug Report
The pykdtree package has a Cython module with a single class definition. Recently a stub was added for this class in a separate kdtree.pyi file (see below). Starting with mypy 1.18.x the stubtest has started failing because mypy considers it a disjoint base, but I'm not sure how that is possible since it is a single class. I have very little knowledge of how mypy investigates a C-level class like this so we could easily be doing something wrong.
To Reproduce
I have a Cython class that you can find the full source for at:
https://github.com/storpipfugl/pykdtree/blob/master/pykdtree/kdtree.pyx
And stub file:
https://github.com/storpipfugl/pykdtree/blob/master/pykdtree/kdtree.pyi
Here's the init-level part of the Cython class:
cdef class KDTree: def __cinit__(KDTree self): ... def __init__(KDTree self, np.ndarray data_pts not None, int leafsize=16): ...And the relevant portion of the stub file:
class KDTree: def __init__(self, data_pts: np.ndarray, leafsize: int = 16): ...Since __cinit__ is a C-level only method it is not in the stub file.
Expected Behavior
Testing the stub with "stubtest" should report no issues. This is true for mypy 1.17.x.
Actual Behavior
error: pykdtree.kdtree.KDTree is a disjoint base at runtime, but isn't marked with @disjoint_base in the stub Stub: in file /home/davidh/repos/git/pykdtree/pykdtree/kdtree.pyi:21 <TypeInfo pykdtree.kdtree.KDTree> Runtime: <class 'pykdtree.kdtree.KDTree'> Note: I did not write the stub file for this, but am one of the maintainers of pykdtree. I don't fully understand the best way to stub a Cython file, but it used to work so I'm surprised by this.
Possibly Related: #19877 #19887 #19740
Your Environment
- Mypy version used: 1.18.2 (and 1.18.1)
- Mypy command-line flags: stubtest pykdtree
- Mypy configuration options from mypy.ini(and other config files): None
- Python version used: 3.12