You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a project of mine, I have a Rust extension (built with pyo3) where some classes cannot be instantiated from Python. I'm currently using this approach, which seems to be working (with pyright, I have not tried mypy yet):
# mymodule.pyifromtypingimportNeverclassFoo:
def__init__(self: Never, /) ->None: ... # valid because `Never <: Foo`x=Foo() # error because `Foo <: Never` is false
However, I would really appreciate it if there was an official way to do this.
Activity
RBerga06 commentedon Aug 11, 2025
In a project of mine, I have a Rust extension (built with
pyo3) where some classes cannot be instantiated from Python. I'm currently using this approach, which seems to be working (withpyright, I have not triedmypyyet):However, I would really appreciate it if there was an official way to do this.