Repository navigation
Description
Update: See #10099 for GSoC 2021 project ideas.
Here are some ideas for larger mypy-related projects for contributors who want to tackle something fairly big (but also with a big potential impact).
Deep editor integrations
Currently it's possible to run mypy daemon from an editor and display the list of errors within the editor, but we could go much further. Possible ideas include going to the definition of an arbitrary reference (such as a method, variable, type, etc.), and displaying the inferred type of an expression. IDEs such as PyCharm can do some of this already, but mypy could support these features more reliably in some cases, since it maintains a very detailed representation of the program internally. Also, this could be very helpful with editors that have no or limited built-in support for these features.
Better decorator support
Mypy can't properly support decorators that change the return type of the decorated function, such as contextmanager (contextmanager is special-cased using a plugin, but this approach doesn't generalize to arbitrary functions). Add support for PEP 612 draft to make this better.
Generalize mypyc IR to allow non-C backends
Currently the IR of mypyc, the compiler we use to compile mypy, is tightly bound to C. This makes it impractical to experiment with alternative backends, such as an LLVM back end or a completely custom back end that directly generates assembly.
Related issue: mypyc/mypyc#709
Faster callables and nested functions in mypyc
Currently calling nested functions and variables with a callable type is pretty slow in compiled code. These limitations reduce the usefulness of mypyc significantly, especially when compiling code that wasn't originally written with mypyc in mind.
Related issues: mypyc/mypyc#713, mypyc/mypyc#712 (both of these would be implemented in a GSoC project)
NumPy support
This is a big topic, but this can be approached a feature at a time. One of the main missing things is "shape types" -- there needs to be a way to express the number of dimensions in an array, at the very least.
Activity
hauntsaninja commentedon Feb 12, 2020
I'd be interested in adding support for PEP 612. I'll take a look at the pyre implementation this weekend, re-read the PEP, and scope out a plan.
JukkaL commentedon Feb 12, 2020
@hauntsaninja Great! If you have any questions, I'm happy to help.
JukkaL commentedon Feb 20, 2020
Another idea:
Detecting potentially undefined or misspelled locals
Some uses of undefined variables are not caught by mypy:
It would be useful to catch these (#2400). A related issue is reporting locals that are never read, as this is often an error (#76).
TH3CHARLie commentedon Feb 20, 2020
GSOC 2020 organizations are announced and mypy is one of them! see https://summerofcode.withgoogle.com/organizations/6527008550420480/
I am interested in Generalize mypyc IR to allow non-C backends and I will manage to have a plan by the end of February.
vpeiter commentedon Feb 22, 2020
Hi!
I'd be interested in working in detecting potentially undefined or misspelled locals.
I will work out a plan and get in contact soon...
sPredictorX1708 commentedon Feb 22, 2020
Hi!!
I am Sarvesh, I am interested in Faster callables and nested functions in mypyc and Numpy support.
I am working on Faster Callables and will get back soon with some solutuon.
edwinjon commentedon Feb 22, 2020
Hello,
My name is Jonathan, I am actually focus on data science and I am really interested to work in Numpy Support. I once questioned regarding the unavailable of "shape types" . By working this project, will help my Data Science works too.
I am going to read the documentations and try to find out some insights which features can be improve for numpy. Thanks
Cheers,
Jonathan
TH3CHARLie commentedon Feb 22, 2020
Hi, @edwinjon and @dubesar, glad to see someone interested in working on the mypy-Numpy topic!
As far as I know, there's a similar work that may help you develop your ideas and plans, check https://github.com/numpy/numpy-stubs.
sPredictorX1708 commentedon Feb 22, 2020
@JukkaL By numpy support I understand that the codes written in standard format needs to be changed to numpy format as for example changing arrays to numpy arrays.
Also by shapes you mean the shapes of the arrays?
Please elaborate that part!!
Also the Faster Callables part I checked the running time of the code and have addressed it in the issue. Please guide me further what has to be done in that, so that I can move in further with the work.
egenedy97 commentedon Feb 24, 2020
Hi @JukkaL my name is Eslam Genedy , I am at third year in University ASU Computer Engineering Department , it is my pleasure to apply for mypy . I have a good knowledge in oop in python and numpy . finally I hope to be contributed in this project thanks in advance
JukkaL commentedon Feb 26, 2020
To support NumPy, we'd need some form of "shape type" support. We want to specify the number of dimensions and the item type of an array, at least. Even better, it would often be useful to specify the exact size of an array, but this will be much harder to implement.
This example is from @ilevkivskyi's presentation from the Typing Summit at PyCon 2019:
This means that
difftakes a one-dimensional array of sizeNand item typeT, and it returns a one-dimensional array of sizeN - 1and item typeT.sum2d, on the other hand, takes an arbitrary-sized two-dimensional array with item typeT, and it returns a one-dimensional, arbitrary-sized array with item typeT.A reasonable goal for GSoC would be to support specifying the item type and the number of dimensions (e.g.
ndarray[float, Shape[:, :]]for a two-dimensional array). This would involve at least these steps (I'm leaving a lot of details out):This is quite a challenging project and requires a deep understanding of mypy type checking internals, so it's really only well-suited for somebody who has substantial experience with working on mypy (or another type checker), or perhaps has completed a course on type theory (beyond a compilers course).
joybh98 commentedon Feb 27, 2020
@JukkaL , I'd like to integrate PEP 612 and take the better decorator support
JukkaL commentedon Feb 28, 2020
@joybhallaa That would be a really useful project! I'd suggest starting by closing a few smaller issues first to get familiar with working on mypy. (The same advice applies to anybody who's interested in diving into a major project. It's best to gradually learn the codebase. Otherwise these's a big risk that there's too much to learn at once, and you'll get discouraged.)
Since PEP 612 involves type inference and type variables, tackling one (or some) of these issues could be a good option: https://github.com/python/mypy/issues?q=is%3Aopen+is%3Aissue+label%3Atopic-type-variables
If you find a promising issue but you are not sure where to start, you may want to ask for hints in the issue.
joybh98 commentedon Feb 29, 2020
@JukkaL I've taken up an issue and after I'm finished with that I'll take up issues that you have mentioned. 👍
pr4k commentedon Feb 29, 2020
Hi @JukkaL I am interested in contributing for adding better decorator support, RIght now I am working on the issues , is there anything which should be done parallely with this and are there any potential mentors for this project idea?
7 remaining items
JukkaL commentedon Mar 24, 2020
Clarification: The Faster callables and nested functions in mypyc GSoC project includes implementing both of the linked issues.
JukkaL commentedon Mar 24, 2020
Note that Detecting potentially undefined or misspelled locals feels too small for a full GSoC project. If somebody wants to work on this topic in the context of GSoC, we can expand the scope by also detecting (some) uninitialized attributes, and preventing unsafe attribute deletions. I can provide more context if there is interest.
shadaabghani1 commentedon Mar 30, 2020
Hello ,
Can you give a bit of details for numpy support ?
JukkaL commentedon Mar 30, 2020
@shadaabghani1 It would be much easier me to help you, if you can ask more specific questions, as the topic is pretty wide ranging. I already gave an overview in this comment: #8373 (comment)
bhack commentedon Apr 2, 2020
@JukkaL I don't know if for the numpy support point you could be interested in this thread: https://llvm.discourse.group/t/numpy-scipy-op-set/768
Akuli commentedon Aug 3, 2020
Currently I'm writing sphinx docs like this and I wish there was a sphinx plugin or something that would ask mypy what the type of each attribute is:
friyaz commentedon Feb 3, 2021
Hey @JukkaL, will mypy participate in GSoC this summer? I am interested in working on the editor integration of mypy.
TH3CHARLie commentedon Feb 3, 2021
Hi, since it may take Jukka several hours before he gets back to you, I will try to share what I know. Mypy is still deciding whether it will participate in GSoC 2021 but we are looking forward to it. For project ideas, once core team members have decided to participate, they will come up with some possible ideas or even post a public issue for brainstorming. The final ideas will most likely be summarized in a new issue. Anyway, please stay tuned to this issue and also the Gitter channel.
friyaz commentedon Feb 3, 2021
Thanks for replying to this. I will add myself to the Gitter channel and try working on any easy to fix issue to get started.
TH3CHARLie commentedon Feb 3, 2021
Cool, apart from mypy's issue tracker, you may also find some easy-to-do issues at: https://github.com/mypyc/mypyc/issues. And for mypyc issues, feel free to ping me for a review
[-]Project ideas[/-][+][GSOC 2020] Project ideas[/+]emmatyping commentedon May 19, 2022
I am going to close this since I don't think there is anything useful to track here, the issues brought up can be tracked in their respective issues.