Skip to content Skip to sidebar Skip to footer

Partial Stub In Pycharm

I would like to introduce partial type annotation to my project. For example for overloading. I found that pep561 introduce partial stub file support. I develop my project with Py

Solution 1:

Indicating to look in the .py for missing top-level reference (CC)

According to PEP 484, this is possible, simply add the following line at the top-level of your .pyi (I checked that it works with PyCharm 11.0.7, EDIT: does not work in PyCharm 2020.3):

def__getattr__(name) -> Any: ...

Indicating to look in the .py for missing attribute/method (BB)

Other libraries (at least typeshed) allow a similar syntax to merge an incomplete class stub with the class definition in the .py

classFoo:
    def__getattr__(self, name: str) -> Any: ...  # incomplete
    x: int
    y: str

However this does not seem to be part of PEP 484, and is not implemented in PyCharm (as of 11.0.7) as far as I know. I just created a request for this feature: I stumbled on this stackoverflow question while looking for a way to merge my incomplete class stub with the class definition and concluded that it is not feasible yet.

Post a Comment for "Partial Stub In Pycharm"