 Welcome Dave to the stage for his talk on using, he's the author of Jedi and he's going to show us in his talk how to use it effectively. Give a round of applause for Dave. Give me a sec. Yeah. That stupid thing won't go away. About five, two, three. We're going to try and have five minutes of questions at the end. So if you're going to leave early, then leave quietly so we can hear what people are asking and hear Dave's answers. All right. So it's really great you're all here. It's great to see so many people and I'm really thankful for all of you. Just quick raise, raise hands please. Who doesn't know Jedi? All right. Who does? All right. That's like 10 person sleeping or something or that, but whatever. And sorry, my, this thing is going totally nuts. But anyway, so I'm Dave and this is like my CV. I'm not kidding. This is really, this is really my CV. Like I would send this to companies and so it's done on a track point. And it kind of shows what I, what I love doing and it's, it's like being creative all over. And I like doing music and like play the guitar is singing and so on. And there's like two things that are not on there. And that's basically I started West Coast swing dancing and I went to Afghanistan in 2013 because it kind of stops there. So what happens from 2013 until now is I did open source development, which is Jedi basically and I did. I went to Afghanistan and Afghanistan look kind of like this. So this is me fighting Taliban or something. And I went there and with like an education focus I teached Afghans. I taught Afghans in computer science and that kind of stuff. So, but I want to kind of get away from Star Wars and Star Wars now and towards Jedi, the, the autocompletion. And so I hope everyone understands what autocompletion is here, right? So it's like this thing that pops up when you write code. And so Jedi is, it's just autocompletion for Python. And it's, it's kind of a new approach. Like there has been rope before and like there's pie charm, but it's kind of different. And it's, it's, it's a project that has has grown quite a lot in the last few months, even it has like 2,200 stars on GitHub and it's, it's well tested and it has only been around for two years. Really. So we, we kind of have an emphasis on Python 3. And that's because, at least I think it's the future of Python. So it works in Python 2, but still like we, we, we do a lot of coding in Python 3. So then would it like the base of Jedi, like what, what's really important is to have a good type deduction. And that's not as easy as you might think, because Python is really dynamic. And it's a different approach than pie charm pie charm has this kind of approach where they, or at least I think they have that approach because their code is not open sourced. So sorry, it is open sourced now, like the whole completion thing. All right. So that has changed. So anyway, what I, what I thought it is, is like they, they kind of build this type tree where you, they just know everywhere the types and like they do it this way and I do it on a lazy evaluation approach where I'm, I'm like just moving from place to place and I try to keep all the values as well to have as much information as possible. And I can show it, I can show you how I do that. And that's, this is a small example. It's like this string object down there goes like Jedi would now work. You have, you have, all right. So you have this completion here. You have capitalized center and so on. And that kind of needs the string object. It, well, it needs to know what the string object is. So it, it goes back and looks where, where is string object defined. It's like that get, get at your thing. So it doesn't get at her on the string and the name and executes it. So basically what get at her does it. It needs the name. So it goes up there. It kind of puts name, the name upper together and then it works. So that's pretty cool because it's that's something you wouldn't expect and another commission to do. Like, um. So, um, Jedi's, then there's like Jedi's parser, which is full tolerant. It basically has to be because autocompletion doesn't really work like rope. The other older autocompletion thing. They kind of use an AST and just delete lines. But that's, then they have to kind of iterate that. And if, if the file is really bucky, they are not able to, to give you any hints. And so basically with Jedi, you can just like give it anything like you can give it a PHP script. And as long as there's like one Python function there, it will work. Um, so way, way more important is the fast parser. That's kind of a strange thing that splits up a file into functions and classes. Um, the idea behind it is that, well, you're doing autocompletion all the time and you're only changing like one line. So if you change only one line, you shouldn't be reparsing that whole tree. It just, it's just a big waste of time. And so what, what Jedi does, it's, it's, it's basically is, it's basically to get rid of that and just, just parse that one function again. And sometimes that's buggy. Like there's, that's, that's why people sometimes think Jedi is not really good or it's, it's buggy or whatever. So if you find a way to reproduce, reproduce issues, like we would be really happy. Um, and there's like one fun thing about this is like if you have Japanese guys as contributors, they will, they will fix that. Like they're the most awesome people to, to have around an open source project because they always, they always kind of go for a performance and, and fix things. And so that has happened a few times here in Jedi as well. Then the dynamic nature of Python is like, we understand that by, by doing, well, by, by, by basically understanding all the get atro stuff and so on. But that doesn't really help a lot because you're not using that. The biggest issue actually of, of, of dynamic stuff in Python is, is lists and sets because you push into these kind of containers and you expect something out of it. And it's hard to understand it because you push from somewhere and it kind of the auto-publish has to handle it. Um, which is as far as I know, again, um, not handled by PyCharm, PyDef and Rope and so on. Um, so this is an example like you just kind of, Jedi understands it even if it's in a for loop or like in a different function. Um, so you have an, an X that is defined as an array. You, you push two times and you kind of, in the end, you end up with completions for both int and string. Like you could now say, well, but the index is not right. Like it should just be an int. Well, we might work on that, but I don't think it's very important because typically you only have one type in there, but you need to know that one type. And so what we end up with is, is, um, Jedi, Jedi really understands a lot about Python. So this, this was kind of the introduction towards static analysis because like if you don't understand all those things, like decorators, generators, list comprehensions and so on. Like if you fail to understand just one bit, one statement, then you fail to understand the whole kind of thing. Because Jedi is recursive and like goes from one place to the next. So if you don't understand the list comprehension, you cannot know the type in the end. Um, Jedi even understands the scriptures like that under, like almost nobody understands those because they're pretty complicated. And there's, uh, there's like exceptions that we just from the beginning on said, well, we were not, we're not going to do that. And that's metaclassa set at her. And I think a few others like locals and globals modifications and dict modifications and like that crazy stuff. Um, which is just too hard to understand. Um, so this led to the idea of, of creating a linter or static analysis. And so this, this came up when I was writing a proposal for a Euro Python in February or something. And so I was like, oh, auto completion is not going to be that interesting to talk about. Like it's just auto completion. Everybody wants it, but nobody really cares how it's done. And so, um, I kind of thought, well, static analysis could be really nice to do with Jedi because we understand the types and we can just do lazy evaluation on everything. So basically evaluate everything so you push. Well, sorry. We push the lazy away and first I thought it was slow, but it turns out it's not that slow. It's not as fast as pylent or pyflakes, but it's, it's okay. Like I'll show you the results afterwards. Um, and it yields very good results just like I worked on it for a month or so. And that's not a lot of time. Like in comparison to what I worked on Jedi in general, it's, it's been like more than two years. So it's just a month. Um, and then it was really fun because there was a talk like who has seen the Haskell keynote. So, and this was fun for me because he just said static analysis is primitive and I'm sitting in there and having a talk about static analysis and how, how we will do that in the future in Python. And so, like he says, well, that's not going to do it. And there's like pylent compile, like the Python compiler and so on. And there they suck, whatever. Um, and so Jedi, well, it does it. But well, yeah. So anyway. But we have to be fair. There's like it wasn't really working on Monday because like I worked on different stuff. I worked most of all on attribute error on attribute attribute errors and type errors from function where you would call like a function with too few arguments or whatever. But, um, so still like I hacked it together in two days and I still drank beer and like, so there's it didn't take a lot of time. And so we will work. We will definitely work on that like to have a proper, proper type errors for all that kind of cases. And here, here's what I worked, what I worked on like this is the slide that I wanted to start with originally, but then like I kind of changed it. And so this is what what what Jedi really does. Well, it's like, oh, we have stir dot upper and well, we forget a P or something. And then it kind of reports it to us the same for like a function that is called with with like an argument. With like three arguments instead of two, like that kind of stuff is working really well now. And that's that was my focus in that kind of in that month before Euro Python, which is which is pretty cool because this is not like this is a very simple example. It works on like pretty crazy stuff. I cannot really show the examples because it's just like very long Python code and then like, but you can just take the example from. Before with get at her and like play around with it and it will still find some some error. So we will just give you an example. I like I thought, well, I don't really have time to test to test against all the libraries or whatever, but I just like a week ago or so preparing to talk. I thought, well, I could just take the most well known library that probably doesn't have any box and. So I took request with which is like 4000 lines like your lip three is not included here. And like scanning, it takes 15 seconds. It yields 51 errors and like 22 errors of those are errors that you want like its compatibility code like imports from. I don't know like Python to imports because I scan it in Python three. And so that kind of stuff. And so that's fine if you see those errors and there's like a few bucks and pretty much everything else is related to mixing classes. Now mixing classes is something that I didn't even think about before. But mixing classes in in Chedi is going to be kind of hard to understand because you have this mixing class and the attribute is defined in a class. That is different than it than the one it's called it's used in. And so that's kind of special, but we might work around it. I don't know, but it's pretty cool. Like you get 50 errors or let's let's say you get 22 errors. That's not a lot of false positives and to show you that you still get errors. If there's a mistake, I kind of prepared this now. No, I didn't prepare this, but so if my presentation would close, but yeah. So I don't see it on my screen so I have to find it. So we can just like first let's let's just scan it. Sorry, it's very small. I forgot to change the size. So scanning, it takes like a few seconds. This module and doesn't yield an error. We change something like this here time C time dot encode remove something. So we have an error now, right? Like it really so it's not just a joke. It works. Yeah, you can, but it's the worst thing ever. Like it's even worse than NumPy, I think, because Chedi is just so comp like the whole idea of running Chedi on Chedi is basically that you run recursions on recursions. And that's very complicated to understand. But it works like Chedi does kind of a limitation in recursions where like, oh, if you're like 10 levels deep, just ignore the rest. And like, because you cannot, you cannot follow everything. There's just no time for that in other completion. We might change that for static analysis, but yeah. So let's just do one other. Yeah, let's just do another one. What did I change? I don't know. Let's just change this function. I hope it works. Yeah, like we get some errors and like you can also like now you would also get pyflakes also yields errors down there. So let's undo it. Let's remove this parameter. So apart from that username thing that is not there, you will not see an error, but let's see the output output here. So it will tell you more because it will tell you, well, yeah, the username is not defined like pyflakes does. But it then also tells you kind of in a typical Python way. O basic of string takes exactly one argument, but two are given. And that's pretty nice. I would like to, but I'm done now with that. So I want to finish here. So what are we going to do in the future? Why is that not working? Yeah, LibreOffice for the win. So we will improve static analysis. That's one of our goals now for like the next few weeks at least. And then there's like the goal of adoption in mainstream IDs, which is already ongoing like spider is doing it with a guy called Steven Sylvester. And there's Piedef is interested. And so one of the things we're going to do if we have enough manpower is refactoring. And then there's one thing I'm really excited about. It's the integration of Sebastian Kraft's Python type annotator, which adds kind of a way to understand NumPy and built-in types way better. He kind of runs a test suite and hacks the Python interpreter to kind of leak every input output type and name. So you kind of know what goes in and what comes out in built-in libraries. So that's going to be at Euro Python sprints. We're going to do that. We're at least three people. So if you would like to join, you're very welcome. And there's like my small future. I've been working on it for quite a long time now. It starts to get financially unsustainable because it's just my savings. They're vanishing. But if you're a company and like you want to have really good static analysis, well maybe you want to hire me or something. And yeah, alternatives are either Kickstarter or more Japanese guys. So here's my contacts. There's two things I want to say. The first is like test well and often there's talks, pie tests, coverage pie and like for open source stuff. There's also Travis, which are just awesome tools. And if you have like a library that has a big test coverage, that's just really cool. And create libraries if they don't exist. So that's really the strength of the Python ecosystem. If you ever thought something should be better, change it. So yeah, we might have time for a question, but probably not. Thank you very much, Dave. We've got time for one question I should think. Can you repeat the question Dave? Yeah, so he asked how well would it work with Wim. And Wim, like I wrote a plugin for Wim called ChediWim, which is working pretty well. And there's another plugin called You Complete Me, which is using Chedi. So they're working really well. There's like three plugins for Emacs. There's two plugins for Subline. There's plugins for a lot of editors. So yeah, I guess that's it. Have a good time. Thank you for coming. Remember Afghanistan is beautiful and like. Thank you, Dave.