ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
558 stars 46 forks source link

mypy support #198

Open ronaldoussoren opened 7 years ago

ronaldoussoren commented 7 years ago

It might be nice to add mypy support to PyObjC by included type information about public API.

Using NewType for enums might be useful for catching obvious bugs.

ronaldoussoren commented 4 years ago

See also #285

PyObjC’s use of basically anonymous metaclasses could be interesting here…

ronaldoussoren commented 4 years ago

https://github.com/python/mypy/issues/7945

This is an issue in the mypy repo about how mypy gets confused about using metaclasses to define class properties, which is a blocker w.r.t. getting useable diagnostics from mypy.

This shouldn’t block work on this issue, that mainly involves generating .pyi files for the framework wrappers (and writing them for pyobjc-core)

ronaldoussoren commented 4 years ago

The mypy issue mentioned earlier might not be a problem, I can probably get away with lying to mypy, there are few if any classes where having both a class and instance method with the same name is relevant for python code.

As with the documentation (#285) I haven't though about including information about convenience methods yet. Those, and information about abc conformance should be added to the typing stubs.

Another open issue is how to deal with ObjC protocols, those are more relevant is recent releases and there Python representation likely confuses MyPy (but as earlier: I might get away with lying about those by treating them as mixin classes for mypy, including providing a mypy plugin that does this for user code). Naming protocol objects is still an issue though.