Latest / Talk Python To Me / #102: Effective Code Reviews
Transcript
- 0:00How do you build reliable software with fewer bugs? Yes, unit testing is part of that.
- 0:04But did you know that code reviews often play a key role in this process
- 0:09and come with many more benefits on top of just bug detection?
- 0:12This week, you'll meet Dougal Matthews. It's Talk Python To Me, episode 102, recorded February 28, 2017.
- 0:20Welcome to Talk Python To Me, a weekly podcast on Python,
- 0:48the language, the libraries, the ecosystem, and the personalities.
- 0:51This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy.
- 0:55Keep up with the show and listen to past episodes at talkpython.fm
- 0:59and follow the show on Twitter via at Talk Python.
- 1:01This episode is brought to you by Rollbar and Hired.
- 1:06Thank them both for supporting the show.
- 1:08Check them out at rollbar and at hired underscore HQ on Twitter and tell them thank you.
- 1:15Dougal, welcome to Talk Python.
- 1:17Hi, thanks. It's an honor to be here.
- 1:19Yeah, it's great to have you here.
- 1:21I'm really excited to bring a slightly different view of technology here.
- 1:25Often we talk about, you know, how do you execute this code?
- 1:28What's the API you call?
- 1:29But let's take a step a little bit back from just writing code
- 1:32and talk about how we work as a team,
- 1:34how we contribute to open source,
- 1:37contribute to our company's code,
- 1:39and things like that through this code review
- 1:41whole conversation that you have here.
- 1:43Yeah, I mean, I spend so much time doing code review
- 1:45just as part of my daily job.
- 1:47It just seems like such an important thing to actually talk about
- 1:49and see how we can improve.
- 1:50Yeah, and I feel like people don't talk about it very much.
- 1:53That's why I was drawn to a talk that you gave at EuroPython
- 1:56that we're going to talk about is,
- 1:58you know, it's great that you're talking about this here
- 2:01because it can actually be either very beneficial
- 2:04to bring in people, kind of to level them up as developers,
- 2:07or it can be confrontational and actually upsetting, right?
- 2:10So I think having this as a thing you study
- 2:14and a thing that you do meaningfully,
- 2:15not just, hey, I have to review your code, somebody said so.
- 2:18Seems like a good idea.
- 2:19Absolutely.
- 2:20At the EuroPython talk, I actually,
- 2:22I'd done a quick sort of raise of hands
- 2:24to see what people thought about code review.
- 2:26And I think it was only around 20% of the room
- 2:28said they looked forward to or enjoyed the code review process.
- 2:32And given how long, how much time people spend doing code review,
- 2:35which was several hours a day, if not more in some cases,
- 2:38then that's just something we need to do better at.
- 2:41Yeah, we definitely do.
- 2:42Before we get to that, though, let's start with your story.
- 2:45How did you get into programming?
- 2:45Yeah, I've got a fairly common story.
- 2:47I think I started messing around with computers when I was young.
- 2:50The first thing I'd done really was learning sort of HTML
- 2:53and I guess CSS a bit later on,
- 2:55just because I first encountered it in some websites
- 2:58and I looked at the view source.
- 3:00And just with that, it kind of led me down this rabbit hole.
- 3:03My dad had actually done something really great
- 3:05when I was a teenager.
- 3:06He embraced it.
- 3:07He was running his own company at the time.
- 3:09And not many people actually had websites
- 3:12for their small businesses.
- 3:13What year was this? Do you remember?
- 3:15It must have been around 2000.
- 3:18Okay, yeah.
- 3:19Maybe a couple of years before.
- 3:20Yeah, I mean, the web was certainly well established.
- 3:23Like the whole dot-com boom was going crazy around that time.
- 3:26It was still not a thing that if you had a business,
- 3:30you had a website, right?
- 3:31Like that was not a one-to-one mapping.
- 3:33It was if you're doing internet stuff
- 3:35or you're a big company like Coke or Chevrolet or something,
- 3:39you would of course have one, right?
- 3:40Yeah, absolutely.
- 3:41I think at that point,
- 3:42it was really out of reach from your regular small companies.
- 3:45So yeah, my dad just basically got me to put together
- 3:49a simple website for him.
- 3:50And honestly, it was fairly terrible,
- 3:52but it was my first kind of step into that world
- 3:54and that direction.
- 3:55And I just, I love the idea of web development since.
- 3:57Yeah, I think it's interesting that the whole view source thing
- 4:02brought so many people into programming, right?
- 4:04It used to be we would go to a store,
- 4:06we'd buy a box,
- 4:07it would have compiled machine instructions on a disk.
- 4:11We'd put those on our computers and run them.
- 4:13And then the web came along and if it did something interesting,
- 4:15you could pretty much just look and study it, right?
- 4:19Yeah.
- 4:19And that actually reminds me of one time,
- 4:21I was just starting and I was trying to figure out
- 4:24why something wasn't working.
- 4:25And actually, I didn't have access to the computer all the time.
- 4:27So what I'd done is I printed about 20 pages of HTML
- 4:30and just sat down and studied it.
- 4:32It wasn't a very good approach, but...
- 4:35I've tried that as well.
- 4:36It's extremely hard to get anything out of it.
- 4:39I did it with C++.
- 4:40Awesome.
- 4:41Okay, so you created the site.
- 4:42What language was that in?
- 4:43It was purely static.
- 4:44So it was just HTML.
- 4:45I'm not even sure if I was using CSS at the time.
- 4:48It might have been a bit early in my learning at that point.
- 4:52But fairly quickly, I moved on to doing PHP.
- 4:55I think it was just because you've seen it everywhere.
- 4:57All the websites ending with .php,
- 4:59like on, I guess, Facebook later on.
- 5:02But they were everywhere at the time.
- 5:04I never really felt quite at home with PHP.
- 5:06It wasn't really the language for me.
- 5:08I'm not really quite sure what it was.
- 5:10I mean, it was just a large number of things.
- 5:12I guess it always felt a bit strange.
- 5:13And I was trying to do more.
- 5:14Like, I was trying to do more object-oriented
- 5:16and think about my code more from an engineering point of view.
- 5:19And eventually, I stumbled on a video by Jacob Cavill Moss
- 5:23when he was introducing Django.
- 5:25It was very early on.
- 5:26It was before Django at one point.
- 5:27And I just picked it up and tried it out.
- 5:29I just loved it.
- 5:30It was great.
- 5:31And that just kind of led me down that path to learning Python.
- 5:35I remember writing a blog post years ago that Django,
- 5:38it's just Python because it was Python that I really liked.
- 5:42I mean, I do enjoy Django, but it was Python and the full ecosystem
- 5:45and everything beyond that.
- 5:46And it just kept on going.
- 5:48Yeah, I hear that's a story sort of like that over and over
- 5:51in that the guys around Django were very just enthusiastic, right?
- 5:57And their enthusiasm wore off on anybody who came in touch with them.
- 6:01And Django just really grew, partly because it's really great,
- 6:04partly because it's Python,
- 6:05but partly just the enthusiasm of getting started with this new world, right?
- 6:09Yeah, absolutely.
- 6:09And I'd gone from sort of hacking on WordPress sites
- 6:13and various PHP frameworks to then suddenly the elegance of Django
- 6:16and Python just defining models and having the admin
- 6:19and all that just there was just amazing, mind-blowing, really.
- 6:23You mean there's objects in architecture and factoring?
- 6:26Oh, my goodness.
- 6:27Yeah, yeah, very cool.
- 6:29So you said you have some strong ties to EuroPython.
- 6:32What's the story there?
- 6:33Are you working with the conference somehow?
- 6:34The reason I wanted to mention EuroPython,
- 6:37I mean, there's actually several reasons.
- 6:40But when I started with Django,
- 6:41I just thought I need to get involved with this.
- 6:42But there's nobody local that I know.
- 6:44I can't find anyone that's doing anything with Python or Django.
- 6:47So as a poor student at the time,
- 6:50I found all the money I had and got myself to EuroPython in 2009.
- 6:55And that's the first EuroPython I went to,
- 6:57and I've been every year since.
- 6:58And I also went to the first and actually the only Euro DjangoCon
- 7:02because after that I got changed to DjangoCon EU.
- 7:04Yeah, and it's just I've met so many people there
- 7:07and I slowly have started to do some small things to help out with EuroPython.
- 7:11So I'm on the program committee this year.
- 7:12And I'll actually take the moment to point out that the EuroPython dates for this year
- 7:17are the 9th to the 16th of July.
- 7:19These are tentative, but I expect they'll be finalized by the time this is released.
- 7:23Oh, yeah, that's really great.
- 7:25Thanks.
- 7:25So if you're anywhere near Europe or you want to go to Europe, right?
- 7:28Check it out, right?
- 7:29What's the URL?
- 7:31I think it's just...
- 7:32It's like EuroPython.
- 7:35EuroPython.eu is the website.
- 7:37Yeah, that.eu.
- 7:37And this year it's going to be in Rumini in Italy.
- 7:39Oh, that sounds awesome.
- 7:40Okay, excellent.
- 7:42Well, there's a possibility I'll make it there,
- 7:44but it's very far away from it.
- 7:46So we'll see.
- 7:47But that's awesome.
- 7:48If people can make it, they should go.
- 7:49I think the Python conferences are something really, really special.
- 7:53There is a different way that people interact with each other there than a lot of typical
- 7:59tech conferences.
- 8:00So yeah, if you can get there, check it out.
- 8:02Yeah, I agree.
- 8:02There's a long-running phrase of come for the language and then stay for the community.
- 8:06And I think that really resonates with me.
- 8:08Yeah, absolutely.
- 8:09So you're doing a lot with EuroPython, a lot with Django.
- 8:13What do you do for your job today?
- 8:15So I'm currently working on OpenStack.
- 8:18I'm employed by Red Hat and I work on the OpenStack project full-time.
- 8:22So I'm focusing primarily on making OpenStack easier to use and install.
- 8:27And I'm also working on a workflow service within OpenStack, which is quite an interesting project.
- 8:32I think that's really good.
- 8:33OpenStack is really a great example of Python doing major stuff.
- 8:39And it's a great contribution, but it is a little bit hard to install,
- 8:42especially if I just want to run it natively on my Mac or something.
- 8:45It's challenging, right?
- 8:46Oh, absolutely.
- 8:47I mean, I think the problem with OpenStack or one of the problems with OpenStack is
- 8:51it's such a wide range of different projects.
- 8:53There's no two OpenStack installations that are actually the same.
- 8:57Some people care about containers or some people can care about VMs.
- 9:00Other people can care about storage, distributed storage, that kind of thing.
- 9:04They're all very different.
- 9:06Yeah.
- 9:06I mean, you're basically installing AWS in a sense, right?
- 9:09Yeah, exactly.
- 9:10Which is quite the thing.
- 9:12And by the way, just S3 is entirely down and the internet is,
- 9:15is in chaos today.
- 9:15So that's quite something.
- 9:17I'm really glad our recording is working.
- 9:19That's great.
- 9:20All right.
- 9:21So let's talk about code reviews.
- 9:23So first of all, let's start with who should be doing code reviews.
- 9:29Like, are these big enterprises?
- 9:31Is this open source?
- 9:33Like, who should care about this?
- 9:35I think everyone should be doing code review.
- 9:37Really, the only reason I can think of to not do code review it, and that would be that you
- 9:41are the sole developer on the project.
- 9:43And obviously, then it's kind of tricky to have a peer review.
- 9:47Most of the time, I'm involved in open source projects and that kind of environment.
- 9:52But I think code review is something that should be in the enterprise and all companies as well.
- 9:57And I think, actually, it's probably more common in open source just because of the nature of how people communicate and collaborate.
- 10:02Yeah, okay.
- 10:03So I tend to agree with you.
- 10:05I mean, I guess if you're on a small team, you work at like a small company, and you have one project, maybe there's some other developers, but they have their other project, and you don't really cross over.
- 10:15It might be a little bit tough to do code reviews, especially if one guy is a C++ person and another person is a Python person or something where they don't know deeply what they're looking at.
- 10:24That's a fair comment.
- 10:25But you're missing out on an opportunity when you're looking at situations like that.
- 10:29Perhaps the Python person becomes ill or leaves the company if nobody else knows what they've been doing, then you're in trouble.
- 10:35At least if they've had a light code review process, they might not need to be as in-depth as in some other situations.
- 10:41They will have some idea of what's going on.
- 10:43Yeah, I think that's a really good point.
- 10:44You also actually pointed out some scenarios where it might make sense, even as a solo developer, to do your own code reviews.
- 10:52Yeah, so this is kind of an interesting thing, which I just stumbled on by mistake.
- 10:57I do some work on one of the documentation projects used in Python.
- 11:00It's called mkdocs.
- 11:02And it's a fairly popular project on GitHub.
- 11:05There's quite a lot of people watching the repo.
- 11:06And I was just hacking away on it.
- 11:08And I opened a pull request onto the project just because I wanted to trigger the Travis build and make sure things passed and were working before I merged it, just to avoid myself making any errors.
- 11:18But in the process of doing that, I left the pull request open for maybe six hours or half a day.
- 11:24And somebody came along and actually made a comment on it and made a suggestion.
- 11:27So it's just by including that process in something that I'm working on, even if I'm planning to just merge it myself anyway, it gives other people an opportunity to get involved.
- 11:37And it actually helped me find new contributors as well.
- 11:40Oh, yeah, that's really cool.
- 11:40So especially if you have open source.
- 11:42But really, if you have a repo that other people are watching, going through the whole workflow, even if it's just a cursory sort of review, lets them know there's like this milestone, like a feature is fixed.
- 11:54And here's the code that fixes that feature, right?
- 11:56Yeah.
- 11:57And also, if you have your CI integrated in that, it will avoid you making any sort of silly mistakes where you've accidentally missed a file or added a file because your test will run against that pull request as well.
- 12:10Yeah, yeah, absolutely.
- 12:11So do you follow or subscribe to the GitFlow style with feature branches and stuff and PRs?
- 12:18How do you guys work together at OpenStack?
- 12:22We basically do master development.
- 12:24Every patch goes into master and then we've got stable branches for releases that are still receiving updates.
- 12:30It's a much lighter workflow than something like GitFlow.
- 12:34I find that GitFlow might work well in a company where you can force everyone to follow the same conventions easily.
- 12:40But in an open source project, I don't think long lasting branches tend to work very well because they just get out of sync and there's different problems going on or they get forgotten about.
- 12:50So I prefer everything just to go into master as soon as possible, but keeping master as stable as possible as well.
- 12:57Yeah, I think that's a really interesting point.
- 12:58And I've worked both ways.
- 12:59I've worked in a company where we basically agreed to do the GitFlow stuff.
- 13:04So every change has its own branch, like a feature branch or a bug fix branch, and then you do a pull request back to the dev or main or whatever to have someone else review it on the way back in.
- 13:16But I've also worked in the – basically, we've got a dev branch and a releases branch.
- 13:20And we just push, you know, merge over to the releases every now and then.
- 13:24I don't know.
- 13:25I've torn.
- 13:26Like they're both – they both have their advantages.
- 13:28One of the things I see about the second one, the latter one, like what you described you're doing is the closer you are to dev on your branch or what you're doing, the less merge pain you're going to have.
- 13:39Like a friend of mine describes sort of being branched as credit card debt.
- 13:45A little bit of credit card debt is fine.
- 13:46If you let it build up for six months, there's going to be a reckoning when you try to fix it, right?
- 13:51Yeah, absolutely.
- 13:52And I think if people are using longer-running branches, then as long as you're rebasing, then you're maybe avoiding most of the problems.
- 13:58That's right.
- 13:58So if you take the dev branch and you merge it into your feature branch every now and then to like keep – basically to keep that time, the work that's been done from the time that you're working on your code to what you're going to check in minimum, that's great.
- 14:12Okay, so in my mind, I guess code reviews are obviously about finding bugs or making sure that you follow certain procedures for, say, security reasons.
- 14:23But you actually said there's a lot to do with like code quality and mentoring and a lot of things.
- 14:31So like what are some of the benefits?
- 14:32Yeah, so this is actually quite an interesting point.
- 14:34There's a paper which is called Expectations, Outcomes, and Challenges of Modern Code Review.
- 14:40This is one of the first academic papers I read about code review, and it's kind of what led me down this rabbit hole.
- 14:45At least I hope I'm remembering the right paper.
- 14:48This data might be from another one.
- 14:50We'll put all the papers, the links to the papers, and people can find the references.
- 14:54Somebody had done some research with Microsoft, and what they'd done is they'd done a questionnaire for the developers before and after the code review process.
- 15:02And they were just finding out why they were doing code review, what they were expecting to get out of code review, and the motivations.
- 15:09And while most of the developers actually stated their primary motivation was to find bugs and find problems, when they took the outcomes of code review, so they looked at the comments and all the different feedback that was in a code review, then they manually classified it based on all the different things that were coming out of it.
- 15:25They actually found out that bug finding was much smaller.
- 15:29While bug finding was still important, it was a much smaller piece of the overall code review process, and there were a lot of other benefits that you'd get out of it as well.
- 15:38I see.
- 15:39Yeah, they probably started out the same sort of mental model, like, okay, how well did we do finding bugs?
- 15:43And like, oh, wait, all these other good things came out of it.
- 15:45Wow.
- 15:45Yeah.
- 15:46Yeah, and I think this is part of why a lot of people don't enjoy code review is because if you're going in just to find bugs, you're kind of going in with a negative stance.
- 15:55You're thinking, what can I find that's wrong with this?
- 15:57What can I find that's broken?
- 15:58It's not.
- 15:59It's a slightly different process.
- 16:01But what they actually found was the biggest outcome was a code improvement.
- 16:05So this is kind of subtle to a bug because the code that was up for review was valid, and it worked.
- 16:10But actually, based on the feedback and the iteration that went on in the code review, they ended up with a better solution in the end.
- 16:16And then there's understanding and shared knowledge between the teams.
- 16:19So it's about having awareness of what other people are doing on different projects or different areas of the code base.
- 16:25Okay.
- 16:26Interesting.
- 16:26Yeah.
- 16:27So you had some interesting quotes, like one from Jeff Atwood, the creator of Stack Overflow, about the value.
- 16:34And it's also one from Steve McDonnell, right?
- 16:36So yeah, Jeff Atwood, who a lot of people will know, he wrote a blog about code review a while ago.
- 16:41And he basically said that the hardest thing about doing code review is finding somebody that you trust enough to do the code review with.
- 16:47But once you actually get into the process, you'll find that every minute you spend in code review is paid back tenfold, which is a really huge sort of payback for your time investment.
- 16:57Yeah, that sounds like a good investment.
- 16:58And then the one from Steve McDonnell.
- 17:00So he was basically, in his book, Code Complete, he compared the detection rate.
- 17:06So how often you're finding bugs in your reviews.
- 17:09And in their study, they found out that unit tests had a 25% chance of catching bugs.
- 17:15Function tests had a 35% chance.
- 17:17Integration tests, 45% chance.
- 17:20But then code reviews were actually between 55% and 60%.
- 17:23So I'm not sure I completely buy those numbers.
- 17:26But I mean, just even think that code review is just as valuable as your unit tests is quite something.
- 17:30I mean, I couldn't live without my unit tests.
- 17:33Yeah, it certainly is interesting.
- 17:34And that book, Code Complete by Steve McDonnell, it's really, it's quite a book.
- 17:38It really has a lot of wisdom, a lot of things like backed up by studies and numbers.
- 17:43And so if you haven't seen that book and you're kind of into this process stuff a little bit, definitely check it out.
- 17:50So the fact that you get better bug coverage than unit testing, that's pretty interesting.
- 17:56Also, how do you feel like unit testing contributes to mentoring and better understanding and sort of team understanding versus, say, like code review?
- 18:06I feel like you would get more of that out of a code review, right?
- 18:09Because you're actually talking, not just writing tests.
- 18:11Yeah, absolutely.
- 18:12So one of the things I covered in my talk was the issues with the sort of the quotes that I gave is they are very focused on bug detection and defection rate.
- 18:21And as you said, there's a lot more to code review, which I cover as well.
- 18:24I think the reason that paper is covered in the bugs is bugs are sort of an absolute thing.
- 18:29Something is a bug or it isn't.
- 18:30So it's very easy to measure.
- 18:32You can see how many bugs have been reported, whereas all of the other benefits, they tend to be a lot softer and a lot harder to actually get a tangible measurement of.
- 18:40Yeah, like that example of what if the Python guy gets hit by a bus, right?
- 18:45Your company is more anti-fragile if you do these types of things, right?
- 18:49It can withstand these problems, whereas I guess it's obvious, like the user can't log in and you get a 500 error on the server.
- 18:56Okay, well, that's a bug, obviously, right?
- 18:58But you can say, well, we could have missed this with, we could have saved this with a test.
- 19:01But also, like, our team works better together.
- 19:04Our team has a better understanding of what each other is doing and the tradeoffs they're making and so on.
- 19:10You can't really test for that.
- 19:11No, not at all.
- 19:18This portion of Talk Python To Me has been brought to you by Rollbar.
- 19:31One of the frustrating things about being a developer is dealing with errors.
- 19:34Ah, relying on users to report errors, digging through log files trying to debug issues, or a million alerts just flooding your inbox and ruining your day.
- 19:42With Rollbar's full-time error monitoring, you'll get the context, insights, and control that you need to find and fix bugs faster.
- 19:49It's easy to install.
- 19:51You can start tracking production errors and deployments in eight minutes or even less.
- 19:55Rollbar works with all the major languages and frameworks, including the Python ones, such as Django, Flask, Pyramid, as well as Ruby, JavaScript, Node, iOS, and Android.
- 20:05You can integrate Rollbar into your existing workflow, send error alerts to Slack or HipChat, or even automatically create issues in Jira, Pivotal Tracker, and a whole bunch more.
- 20:14Rollbar has put together a special offer for Talk Python To Me listeners.
- 20:17Visit Rollbar.com slash Talk Python To Me, sign up, and get the bootstrap plan free for 90 days.
- 20:23That's 300,000 errors tracked all for free.
- 20:26But hey, just between you and me, I really hope you don't encounter that many errors.
- 20:30Loved by developers at awesome companies like Heroku, Twilio, Kayak, Instacart, Zendesk, Twitch, and more.
- 20:36Give Rollbar a try today.
- 20:37Go to Rollbar.com slash Talk Python To Me.
- 20:40Yeah, so how do you feel like automation fits into this?
- 20:50So like continuous integration and whatnot?
- 20:54So I really strongly believe that you should automate as much as possible.
- 20:58Anything that can be automated that isn't is essentially wasting your time.
- 21:02And for most people, their time is the most precious thing.
- 21:06So this means that you should be automating your linting.
- 21:09So this is like your PEP 8 checking or your FLAC8.
- 21:12Yeah, you had an interesting quote where you said something to the effect of this whole thing often gets set up as an adversarial sort of relationship.
- 21:20Like, okay, these guys sit on the side of that table.
- 21:22You sit here.
- 21:23We're going to review and tell you what you did wrong and how you need to fix it.
- 21:28And one of the things that code reviews are supposed to do is like say, well, you're not following this coding convention or you didn't do this thing.
- 21:37You know, you didn't document this or name this correctly or whatever.
- 21:40Right.
- 21:40And if that comes from a human, it seems super nitpicky.
- 21:44But if it comes from a machine, everybody is sort of subjected to the thing absolutely uniformly.
- 21:51So you're like, oh, yeah, FLAC8 told me that should have an underscore and not camel case or whatever.
- 21:56Right.
- 21:56Yeah, absolutely.
- 21:57The sort of the feedback from an automated machine.
- 22:00So in terms of also including verifying the tests are running, it doesn't feel negative.
- 22:05It doesn't feel like the code is judging you.
- 22:08But sometimes if somebody comes along and reviews something that you've been spending a lot of time on that, but then they just point out different small little things that they think would be slightly nicer formatting, then that can be infuriating.
- 22:19Yeah, I think it's infuriating, but it also can't be anyway.
- 22:22But I think the other part that is there is if your job is to be the reviewer, you don't want to spend your time going, yeah, you named that wrong.
- 22:31Yeah, that needs a comment.
- 22:32Yeah, that needs a doc string.
- 22:34Like that is not that is like a job that robots could do and robots should do.
- 22:39Right.
- 22:39You should say like, no, no, I think this algorithm is when we scale up, this is not going to scale or this is a stateful thing you're doing.
- 22:47That means like we can't load balance it.
- 22:48So we need to do that different.
- 22:49Like that is the kind of thing people should be contributing to and not spending the energy on camel case, camel case, doc string.
- 22:55Yeah.
- 22:55Right.
- 22:56Yeah.
- 22:56So focusing your time on the design and the architecture and the actual solution to the problem is just so much more productive.
- 23:03Yeah.
- 23:03And so you said you were trying to rename this process to like something other than a review, right?
- 23:08Yeah.
- 23:09I have a bit of an issue with code review.
- 23:12I think review is a slightly negative feeling about it.
- 23:15If you think of something like a performance review at work, that's rarely a good thing.
- 23:19And your manager says, okay, we need to have a performance review.
- 23:21I much prefer to think that it's going to be a code collaboration or a code discussion.
- 23:27It's something that you're working on with someone else.
- 23:30And I think we should try and encompass that more.
- 23:31I don't realistically think we'll ever change the name at this point, but that's how I perceive it in my head at least.
- 23:37Yeah.
- 23:37Yeah.
- 23:38That's cool.
- 23:38I think code collaboration.
- 23:39To me, maybe code conversation, right?
- 23:42Something like this, right?
- 23:43Yeah.
- 23:43That's awesome.
- 23:44Yeah.
- 23:44I mean, certainly in the open source space, I feel like these can almost be a conversation starter or an introduction to somebody maintaining an important project.
- 23:56Like you can go look at some code, fork it, do some work, and then your pull request like starts the conversation.
- 24:02Like here's how I think I can both contribute to your project and improve it.
- 24:06And then, you know, you get to know that person a little bit, at least by going through and reviewing their code back and forth on, well, you didn't think about this in our project and you're going to have to account for it and so on.
- 24:17Right?
- 24:17Yeah.
- 24:18And I think it's really important when you submit a change to a project that you state that you want to have feedback.
- 24:30I just want you to merge this.
- 24:31And I was like, well, you've only just opened this pull request.
- 24:33We're only just starting to talk about it.
- 24:35I've never seen this before.
- 24:36So this is like the start of the conversation.
- 24:39And I think both people need to go into it at that point.
- 24:42Whereas sometimes somebody's maybe been working for a week on something and they feel like when they opened the pull request, they kind of feel like they've done.
- 24:49They feel like they've finished.
- 24:50But that's not the case.
- 24:52Yeah.
- 24:52No, it's the beginning, right?
- 24:53The beginning of the conversation.
- 24:55What would you recommend to have made that person's experience better?
- 24:59Should they have opened an issue and said, I'm going to do a pull request.
- 25:02Here are my intentions.
- 25:03Here's the problem I've identified and what I think I'm going to do.
- 25:06I'm sort of personally torn because on one hand, actions speak much louder than words.
- 25:12Like here is the code that I have written that will fix this for you.
- 25:15Puts you in a different place than somebody who opens an issue and sort of like almost complaining.
- 25:19Right?
- 25:20So they come with more credibility, but at the same time, they put a lot of energy into it.
- 25:24And they may have gone in a path that was incongruent with what you're doing.
- 25:26Right?
- 25:27So what do you think?
- 25:27Yeah.
- 25:28So I think in this case, you just need to judge it yourself.
- 25:31Really?
- 25:31There isn't a standard answer.
- 25:32Sometimes what you're working on is fair.
- 25:35It seems fairly obvious.
- 25:36So it's fairly small and contained.
- 25:37And then you should just go ahead and do the pull request.
- 25:40But if you feel like there's maybe more discussion, you're not sure about how it should work, then it's better to go towards an issue first.
- 25:46I do think that sometimes it's actually easier to express what you want to do in code.
- 25:50Like you're just messing around.
- 25:52So I think it's also fine to just go straight to the pull request.
- 25:55But you should just always have the expectation that this is a very first draft and it will change or it could change.
- 26:01Yeah.
- 26:02I think maybe think of it as like a draft of a paper sort of thing.
- 26:05It's a pretty interesting way to think about code.
- 26:07Right?
- 26:07Okay.
- 26:10So when you're authoring changes, don't start with a code.
- 26:13Well, what should you start with?
- 26:14You should either be starting.
- 26:16Well, you can start with the code if you want to, but it's always good to start with a discussion first on an issue or sort of a bug report somewhere where you can actually flesh out what it's going to be.
- 26:25But that isn't always needed if it's going to be a much smaller change in the end.
- 26:29Yeah.
- 26:30Also, you know, understanding the context of where that person's coming from, where the project is.
- 26:36Right?
- 26:37Like on one hand, you might, it would be very easy to look at one algorithm and go, this algorithm does everything in memory.
- 26:42It loads it all up, all this data up at once.
- 26:44And it's going to be super slow.
- 26:45We can't do this.
- 26:46Well, that's true if you have a billion records.
- 26:48If you have 20, it's totally fine.
- 26:51And the billion record solution would actually make it worse.
- 26:53Right?
- 26:53So understanding context, I think, is super important.
- 26:55Yeah.
- 26:55And when you actually provide a change, it's really useful to tell people both why you were doing something.
- 27:01Sorry, what you were doing and why you were doing it.
- 27:03I quite often see commit messages or pull requests that only really cover one of the two.
- 27:08And I think you really need to understand both as a reviewer to really give a thorough review to that code.
- 27:14Yeah, for sure.
- 27:14I think, obviously, you have to keep that in mind no matter what.
- 27:17But I feel like in open source, you don't necessarily know how people are using your code as opposed to, like, within your company, like, well, it's that website.
- 27:24We know what we're doing.
- 27:26We know what the traffic is.
- 27:27We know how that's going to look.
- 27:28Right?
- 27:28So it seems almost more important in the open source, open space world rather than confined behind your company's wall.
- 27:36Yeah, absolutely.
- 27:37So say, for example, you need to add a new sort of method to a function for some reason.
- 27:42If you just write in your pull request, added parameter A to this function, then that's not very useful.
- 27:48You need to also explain why you're doing that.
- 27:50What is the actual advantage to this as well?
- 27:52Yeah, and how you're not going to break everybody's code by doing it.
- 27:54Yeah.
- 27:54Another interesting piece of research that you pulled out, something from Mozilla, was people actually find more issues and give better feedback on small changes, small PRs and so on, rather than large ones.
- 28:09Even though the large one surely has more things to address.
- 28:11This happens because reviewers are just overwhelmed by a big change.
- 28:15And I actually seen someone tweet about this.
- 28:18Basically, they decided that they should just submit bigger changes because people do less thorough reviews and they get their code in more easily.
- 28:25Sneak it back.
- 28:26Yeah, that's obviously not the idea here.
- 28:28So if you can just keep your changes really sort of contained to one particular thing, one particular issue, and ideally touching less files within the project.
- 28:37Although, obviously, sometimes you need to touch multiple files.
- 28:39It just makes it easier for someone to review and get their mind around it and really understand what's going on.
- 28:45And I think that's why the smaller changes then get a much more valuable review, whereas the bigger changes, they tend to nitpick at different things, but they've maybe not quite been able to wrap their head around everything that's going on in this review.
- 28:57Yeah, so do you recommend sort of having one concept per check-in type of thing rather than, I did all my work for the day, so I'm done, so I checked it in.
- 29:06But here's this little change I made, then I reformatted this thing, and then I addressed this performance thing over here rather than just all at one shot.
- 29:15Would that get better feedback?
- 29:16I'd definitely go for splitting that up into multiple reviews.
- 29:20I actually find that you mentioned that you reformatted something in that example, and I actually think that can really make it harder to review something because the diff could be 10 times bigger just because they've also reformatted the code at the same time.
- 29:33They do that as two individual changes, and you can actually see, okay, this is where they've actually made the functional change.
- 29:39This one's just laid out.
- 29:41Okay, they're both fine.
- 29:42Something like this can depend a bit based on the tool that you're using.
- 29:45So if you're using a GitHub pull request, if you just have two commits in your pull request, then that would be fairly easy to review in that case.
- 29:52But something like Garrett, which only allows one package at a time, it's a bit tricky.
- 29:56Yeah, sure.
- 29:56What do you think, what contribution to this do you think GitHub has made?
- 30:00How important is all of this sort of well-known, commonly used infrastructure that is kind of GitHub.com for code review, code collaboration?
- 30:10Do you think the tools are adjacent?
- 30:12I think they're reasonably good.
- 30:13They've actually made some changes over the last, I can't remember when exactly, but I think over the last six months or so, they added a whole bunch of features.
- 30:20And at least some of them appear to be inspired by Garrett and maybe other code review tools as well.
- 30:25I think they're improving the process.
- 30:28Originally, I think it was almost too simple.
- 30:31But actually, for small projects, it seems to work quite well.
- 30:35When you see larger projects on GitHub using pull requests as their primary code review, they tend to come up with a very complicated system on top of that with labels.
- 30:43Or they maybe, I think Facebook has bots on all their different projects that are like progressing things on and sort of marking them as failed or not.
- 30:50So yeah, I think they've done a great job in making code review accessible to everyone to at least a degree.
- 30:56But yeah, I still think there's space for improvement there.
- 30:59Yeah, it's interesting.
- 31:00I mean, it's not necessarily true that the code that, you know, say you guys are using for OpenStack or Python is using for CPython is necessarily the best same set of tools for people with a thousand line project.
- 31:15Right.
- 31:16Like there's overhead in these bigger things that the smaller ones would actually suffer from it being there.
- 31:21So it's always a tension, right?
- 31:23Yeah, absolutely.
- 31:23I mean, so we use Garrett for OpenStack and it's a Python open source project.
- 31:29So that's quite nice.
- 31:30In all honesty, it is very hard to use.
- 31:33It's also extremely ugly and it takes a long time to just get used to using it.
- 31:37But once you do get to that point, I find it really good.
- 31:40Whereas GitHub, I feel like that's maybe the opposite.
- 31:44Whereas it's really easy to use, but you start to hit up on the limitations of it fairly quickly.
- 31:49Yeah, I think that's totally, totally correct.
- 31:52So, I mean, even simple stuff as like nested issues or to-dos, right?
- 31:58Like I'm not even sure if GitHub supports those, but it can be like, well, we want to do this thing, but there's actually five things we have to do to make that happen, right?
- 32:04That could be important.
- 32:06Okay.
- 32:06Now, you talked about how if you're the reviewer, you shouldn't see this as like I'm assigning a grade or judging this person's code, but maybe think of it as like a shared responsibility with the author.
- 32:18And you had a nice picture of like bunnies or guinea pigs or something.
- 32:21Yeah, it was a guinea pigs.
- 32:24I think I found that on Flickr.
- 32:25Yeah.
- 32:26I think it's really important when you're reviewing something that you take on ownership of that code as well.
- 32:31Because effectively, I think the author of the code and the person that's approved and merged it are just as responsible for it ultimately.
- 32:38This may not work in practice sometimes because people that submit the changes that get merged, they'll disappear on an open source project, for example.
- 32:45You should really be trying to share that responsibility.
- 32:48And I think this sort of highlights an issue that you would see with something like Git Blame because you would sometimes use Git Blame to look through the history of a project and see who has written what.
- 32:58But that will only ever show you the author or sometimes the merger, depending on how you're doing things.
- 33:03It won't show you everyone that's involved in the code review process as well.
- 33:07And I think surfacing all these different people is useful.
- 33:10As a side, I think Git Blame is a terrible name for the command in general.
- 33:14But I think just having something which helps you find everyone that knows about this.
- 33:19It's more about finding someone that has the knowledge here rather than finding someone to blame, in my opinion.
- 33:24Yeah, I agree.
- 33:25I certainly blame.
- 33:27While sometimes it feels appropriate, you're like, all right, what is this?
- 33:31Who wrote this?
- 33:32It's not a real positive thing, right?
- 33:34And you're right.
- 33:35It only captures the final commit, which it could have actually just been the person who just reformatted it because there was a problem, right?
- 33:40It doesn't even necessarily mean they created it.
- 33:43Yeah, or moved the code around.
- 33:44Yeah, yeah.
- 33:45Something like that.
- 33:45You also said that code contributions are like puppies.
- 33:49Yeah, so the picture of the puppy is actually my dog when she was only a couple of months old.
- 33:54But it's quite a nice quote.
- 33:57I don't know where it came from, so I can't attribute it correctly.
- 34:00But somebody said that code contributions are like puppies.
- 34:03Everyone loves them.
- 34:04But you need to look after them.
- 34:06You've got to walk them.
- 34:07You've got to feed them.
- 34:08You've got to care for them.
- 34:09And this is the same for any code contributions that you receive.
- 34:12You need to make sure that they continue to work.
- 34:14You need to make sure they're documented and so on until you can deprecate it.
- 34:18And that often is quite hard to do in open source projects.
- 34:21Absolutely.
- 34:22Well, and I think the puppy analogy is nice.
- 34:24Like everybody loves them and they're cool when they're nice and cute.
- 34:27But, you know, when they're four years old and it's raining and you're busy, do you really want to walk them, right?
- 34:32Or do you want to leave the party early because the dog needs to go out?
- 34:36It's easy to say, well, I just want to change this behavior a little bit.
- 34:39I just want to add this function.
- 34:40I just want to like add an overload or a default parameter here and think how hard can that be?
- 34:47It's like two lines of code.
- 34:49I'll check it in.
- 34:49Well, there's the documentation.
- 34:51There's that video you recorded showing people how to use it that you have to re-record.
- 34:56There's this thing you have to redeploy.
- 34:58There's this, these, like they can, the smallest changes can expand in like large ways, right?
- 35:03So under, like having somebody who knows that, like it's reviewing and going, you don't really fully appreciate the cascading changes that the small change is going to have, right?
- 35:11Yeah.
- 35:11And I think it's, it's something that open source maintainers in particular should feel like they can do, they can reject code more basically on this basis.
- 35:20I think people quite often feel pressured to accept contributions.
- 35:23Right.
- 35:24I worked hard on it.
- 35:25And so why don't you want to accept it?
- 35:27It works.
- 35:27It passes the test.
- 35:28Yeah.
- 35:28But then they then are responsible for looking after that code for forever.
- 35:34Yeah, yeah.
- 35:35This portion of Talk Python To Me is brought to you by Hired.
- 35:49Hired is the platform for top Python developer jobs.
- 35:52Create your profile and instantly get access to 3,500 companies who will work to compete with you.
- 35:57Take it from one of Hired's users who recently got a job and said,
- 36:00I had my first offer on Thursday after going live on Monday and I ended up getting eight offers in total.
- 36:05I've worked with recruiters in the past, but they've always been pretty hit and miss.
- 36:08I tried LinkedIn, but I found Hired to be the best.
- 36:11I really liked knowing the salary up front.
- 36:13Privacy was also a huge seller for me.
- 36:16Sounds awesome, doesn't it?
- 36:17Well, wait until you hear about the sign-in bonus.
- 36:19Everyone who accepts a job from Hired gets $1,000 sign-in bonus.
- 36:23And as Talk Python listeners, it gets way sweeter.
- 36:26Use the link Hired.com slash Talk Python To Me and Hired will double the signing bonus to $2,000.
- 36:31Opportunity is knocking.
- 36:33Visit Hired.com slash Talk Python To Me and answer the door.
- 36:36You know, I had a recent experience with this.
- 36:45I suggested some change to pyramid the web framework and they're like, great.
- 36:48And if you're willing to be the maintainer of this part of that feature for two years,
- 36:52then we're totally happy to accept that.
- 36:54Is there a simpler way we can solve this problem?
- 36:56Maybe.
- 36:56So they subscribe to the puppy philosophy.
- 37:00Yeah.
- 37:00I mean, it's nice that they were willing to give you that opportunity because actually it's
- 37:04quite hard to get to that point of trust with people sometimes because a lot of people might
- 37:09promise to support something for two years, but then they'll just disappear shortly after.
- 37:14That's right.
- 37:15That's right.
- 37:16The other thing that I thought was pretty insightful is you said that not just senior
- 37:21devs should be reviewing code.
- 37:24It shouldn't be a top down, like I'm above you.
- 37:26And so I look down on your stuff and I tell you whether it can be approved, but also juniors
- 37:31should do review, maybe even a seniors check-ins, right?
- 37:34This is a mistake which I've seen in a couple of companies.
- 37:37Not recently, actually.
- 37:38So hopefully it's sort of a trend that's dying now.
- 37:41I've seen cases where only the seniors were allowed to review the code and the juniors
- 37:45would then sort of be subject to the review, but they would never get the chance to review
- 37:49themselves.
- 37:50There was actually a study which found that senior developers were actually doing slightly
- 37:54better code reviews just because of their experience.
- 37:57They also found that junior developers most quickly improved and most quickly became on par
- 38:03with the other seniors by doing code reviews themselves.
- 38:07I think that really highlights back to all the other benefits that come out of code review,
- 38:11like with the shared knowledge and the shared understanding.
- 38:12That's how the juniors become seniors.
- 38:14Yeah, absolutely.
- 38:15I totally think that's a great idea, a great point.
- 38:17Sure, they'll find fewer bugs, potentially, because they don't really know as well to look
- 38:22for them.
- 38:23Maybe their suggestions will be pushed back upon.
- 38:26Like, I suggest you rewrite this in a simple way.
- 38:28Well, no, no, it won't scale and we have a million users, so on and so on.
- 38:31But even just having that conversation, making them actively think about it and propose those
- 38:36changes, whether or not they actually make it through, the value has already been gained
- 38:40from that, right?
- 38:41Yeah, absolutely.
- 38:42Okay.
- 38:42Very nice.
- 38:43You also said having a review checklist might help.
- 38:46It seems to me like that could depersonalize it a little bit.
- 38:49Like, look, these are the things we're going to check for, so we're going down the list
- 38:52and it's not me being a jerk to you.
- 38:54This is a list.
- 38:55Like, it applies to me too.
- 38:56A code review checklist can be very beneficial because it gets everyone really on the same
- 38:59page and everyone's kind of reviewing to the same standard and the same expectations.
- 39:04The one thing you need to be careful with is that you don't include anything that could
- 39:07be automated because there's temptation.
- 39:08It's easier to write something on a sort of a review policy than it is to automate it.
- 39:13So you just need to make sure that that doesn't happen.
- 39:15But otherwise, I think it's a really good idea for projects to explicitly sort of state what
- 39:20they're expecting.
- 39:21And this can be useful both for the reviewers and also somebody that is submitting something
- 39:25for review because they know what they are working towards.
- 39:27Yeah, that's cool.
- 39:29Certainly, it seems like you could just build the checklist and go, okay, what of this can
- 39:32we automate?
- 39:32And we're not going to use this checklist until we've gotten everything that can be automated
- 39:37automated.
- 39:37Yeah, that's actually a good idea.
- 39:38So that'd be a really nice way to build up your priorities.
- 39:41Yeah, for sure.
- 39:41Like automated linting and things like that.
- 39:44We already talked about the bots providing the nitpicky stuff and so on.
- 39:48You also suggested possibly having multiple reviewers.
- 39:51Yeah.
- 39:52Not a one-on-one situation.
- 39:53Yes, I think a lot of people actually assume that core review is essentially one-to-one.
- 39:57You have one person doing the authoring and one person doing the reviewing.
- 40:00You can get real benefits from having multiple reviewers.
- 40:03So this is something I hadn't done before working on OpenStack.
- 40:06And in OpenStack, every change has to have at least two core reviewers.
- 40:12And also then they'll often have other reviewers that are just community members that are interested.
- 40:17So every change is, I actually looked at the numbers at one point, every change on average
- 40:21was getting between three and five people reviewing it.
- 40:24So they were a huge number, but only two of those were going to be in-depth reviews.
- 40:28And it's just really surprising to me how often I will review something and then someone else
- 40:34will come along and review and actually see something that I missed.
- 40:37It helps multiply the benefits of the shared knowledge and the shared understanding.
- 40:40It also takes the pressure off code review.
- 40:43So you can not feel like you're the only person that's verifying this.
- 40:47You don't feel as responsible, but you share that more.
- 40:51It's not like you're the goalie.
- 40:52And if it goes past you, it's over, right?
- 40:55Yeah, exactly.
- 40:55Interesting.
- 40:56Yeah, definitely talked about the short reviews.
- 40:59Do you think it would be beneficial to kind of reverse that as well and have multiple contributors?
- 41:06So if I'm submitting a patch, this probably works better in a corporate space.
- 41:10But if I'm submitting a patch and it's getting reviewed, I also have to like sit in on the review,
- 41:16maybe be a reviewer, maybe just observe someone else's code being reviewed as well.
- 41:22Like having that other side of the story not be one to many.
- 41:26And that sounds a little bit like doing pair programming in maybe an asynchronous way.
- 41:30So you have multiple people contributing to the project.
- 41:33And I think that can work well, but it does probably require that you know people a bit more.
- 41:38So this is something that I do see happen in OpenStack fairly often.
- 41:42Some of my colleagues, if I see that they've got a review up and then there's a small addition or something else that I can make to it,
- 41:48I'll just push a change to that.
- 41:49I guess it also requires the tooling to support this.
- 41:53It wouldn't be quite tricky in GitHub, for example, because you'd have to send a pull request to the branch,
- 41:58which is the original pull request, and it becomes a message.
- 42:01Yeah, yeah, yeah.
- 42:02I'm certainly thinking like this is a place where you guys sit down over like a shared projector and have this conversation.
- 42:08You know, something like that.
- 42:09They get, you know, pure open source where it's all asynchronous.
- 42:12I'm not sure it makes any sense.
- 42:13I work from home remotely, so I always think about everything as being async and whatnot.
- 42:19Yeah, yeah, same here.
- 42:21I work from my house as well.
- 42:22Okay, so all that stuff is really interesting.
- 42:25Now, we talked a little bit on the tools that you might use to make this work.
- 42:30So we've got Garrett, which is open source Python.
- 42:34It's like a web app that you install.
- 42:35Do you like connect it to your Git repo and it watches the branches or how does that work?
- 42:40There are integrations for GitHub, which I've not actually used them very often.
- 42:44But the way you interact with Garrett is with a Git plugin, which is actually also written in Python.
- 42:50So you pip install a project called git-review, and that gives you a new command, which is git space review.
- 42:57And there's a little configuration file in your code repository,
- 43:01and then that will send the review up for review to the destination of the Garrett installation.
- 43:07And you will have an account with Garrett already with your SSH key in there, so it knows who you are.
- 43:12Nice. I see.
- 43:13So you do like a push to that origin or something, right?
- 43:16And then it has it.
- 43:17It doesn't necessarily have to hook into the full code repository.
- 43:21Yeah, so the git review, it does a couple of different things, the command.
- 43:25But primarily what it does is it sets up the remote for you and pushes and creates a branch for your change on the remote one
- 43:30and gives you like a review number and that kind of thing.
- 43:32Yeah, yeah. Very cool.
- 43:33And then GitHub, obviously, we've talked about that a lot.
- 43:36They just added like full proper code review where you can go to a check-in and like expand it out and comment and stuff.
- 43:41So GitHub's coming along.
- 43:43There's also Bitbucket.
- 43:44Probably a lot of people use Jira.
- 43:46I don't know the source usage relative to GitHub, but it seems like at least issue and review stuff happens a lot in Jira.
- 43:52I'm not sure if Jira has code review built in, but I've not really used it.
- 43:55The one I do hear quite good things about is Fabricator.
- 43:58So this is actually written in PHP, I think.
- 44:00And I also think it came out of Facebook originally.
- 44:02I've heard of some people really having success with that.
- 44:06Again, I've never actually used it myself.
- 44:08The only two that I really have recent and extended experience with are GitHub and Garrett.
- 44:14Sure.
- 44:15Okay.
- 44:15Excellent.
- 44:16So some tools out there, I know actually in this whole space, there's like a billion tools, right?
- 44:21There's a whole bunch of small things, but these are some of the big players in our space.
- 44:25Very cool.
- 44:25I think, you know, we're kind of getting to the end of the show.
- 44:27We're running low on time.
- 44:28Let me wrap it up with my final two questions, as always.
- 44:32So if you're going to write some Python code or any code, what editor do you open?
- 44:35I use Vim all the time.
- 44:37Yeah.
- 44:37I work in so many remote servers and VMs that I have some scripts to kind of set up my Vim environment on that machine.
- 44:46And then it's just, it's great.
- 44:47Oh, nice.
- 44:48Yeah.
- 44:48That's super portable.
- 44:49Awesome.
- 44:49Okay.
- 44:50And favorite or favorites from the PyPI package.
- 44:54Have we passed 100,000?
- 44:55I'm going to look at what you're thinking.
- 44:58We're definitely getting up there.
- 44:59It is at 99,706.
- 45:02I think tomorrow will be the 100,000 packages.
- 45:05So there are rounding up 100,000 packages on PyPI.
- 45:09What ones do you recommend for people to check out that are awesome?
- 45:12So I think most of my favorites are the fairly common ones that people know about.
- 45:16So I picked a couple of more obscure ones here, which I think are just quite nice.
- 45:20And they've been useful in my development process.
- 45:22So Vulture is one that you actually covered on Python Bytes.
- 45:26You referenced one of my blog posts about it.
- 45:28And basically, it's a tool for finding dead code.
- 45:32So it finds functions which are never used.
- 45:34And that kind of thing.
- 45:36It's just really useful.
- 45:37I think that's a really cool project.
- 45:39And I'm glad we talked about it.
- 45:40Because nothing is more frustrating to me than spending half an hour trying to understand what a function does in the context of an app.
- 45:45To realize, oh, I don't understand it because it doesn't do anything.
- 45:49Right?
- 45:50Like, it's super cool.
- 45:51So very nice.
- 45:52It's amazing how often I've found projects which have a function and it's only has a unit test for it.
- 45:58But it isn't used anywhere else.
- 46:00But because there's a unit test, everything that inspects the code thinks it's being used.
- 46:05But with Vulture, you can exclude any uses in your test cases, for example.
- 46:09And then it'll highlight it.
- 46:11So that works quite nicely.
- 46:12Oh, very cool.
- 46:12Very cool.
- 46:13All right.
- 46:13What's the next one?
- 46:14The next one that I've been using recently is called pip debt tree.
- 46:18So that's one word.
- 46:19And what you can do with pip debt tree is you can provide it the name of a package which is installed in your virtual land.
- 46:25And I'll actually give you the tree of requirements for that.
- 46:28So you can see where another package came from, why it's there.
- 46:31Right.
- 46:32You might be looking at your virtual environment via pip list and go,
- 46:35why do I have beautiful soup installed?
- 46:36Like I didn't install that.
- 46:37Right.
- 46:37And this would tell you, right?
- 46:38It was installed because of this, which installed that, and it needed that or whatever.
- 46:41Yeah.
- 46:41And it prints it out in quite a nice sort of tree structure.
- 46:44And then it's got a few other things.
- 46:45Like you can do a reverse of that.
- 46:47So you can have it tell you all the requirements for a package,
- 46:50or you can have it trace where something came from, like the opposite end.
- 46:54So from the leaf node of the tree rather than the trunk.
- 46:57Oh, that sounds awesome.
- 46:58I didn't know about that.
- 46:59And the final one you said is entry point inspector.
- 47:01Yeah.
- 47:01So this is probably the smallest one.
- 47:03And I guess this is because I do quite a lot of Python packagings.
- 47:06But if you have, so say for example, when you install pip deptree,
- 47:12it creates the pip deptree command for you that you can use in your terminal.
- 47:16But actually trying to find out where these commands come from is quite difficult.
- 47:20So entry point inspector will actually inspect the Python entry points that are defined in different setup.py.
- 47:27And then I'll list them out.
- 47:29So you can see where all these commands are coming from, where they're defined, what packages are coming from.
- 47:33That sounds really cool too.
- 47:34These are all great.
- 47:35Awesome.
- 47:35Thank you for sharing them.
- 47:36Final call to action.
- 47:38What should people do after listening to this?
- 47:39They're all inspired about code review.
- 47:41If people are inspired about code review, they should just think about how they can improve their process.
- 47:46They should start thinking about what they're doing, build improvement into your code review process.
- 47:51So every now and then maybe have some kind of retrospective and think about what's working, what isn't working, and just try and improve that.
- 47:57Yeah, remember why you're doing it, right?
- 47:59Yeah.
- 48:00Absolutely.
- 48:01Okay.
- 48:01And then EuroPython's coming up, right?
- 48:03Yeah.
- 48:03So I did touch on this earlier, but EuroPython is going to be this year on July from the 9th to the 16th.
- 48:10These dates are officially tentative, but I think they will be finalized by the time this episode is out.
- 48:15I have to put that disclaimer in.
- 48:16And people should start thinking about talks.
- 48:19So we will have a call for papers coming out very soon as well.
- 48:21I would love for people to speak.
- 48:23If people have never spoken before, I'd be happy to speak to them about it.
- 48:27and help them sort of find something that they want to talk about, I think that'd be good.
- 48:31Yeah, it'd be great.
- 48:32It's a very welcoming community, so a good place to get started with public speaking, right?
- 48:37Yeah, absolutely.
- 48:38It's where I first started speaking.
- 48:39Well, Dougal, thank you so much for being on the podcast and sharing all these ideas with us.
- 48:43It's been great.
- 48:44Thanks.
- 48:44I really enjoyed it.
- 48:45You bet.
- 48:45Bye.
- 48:45This has been another episode of Talk Python To Me.
- 48:50Today's guest has been Dougal Matthews, and this episode has been sponsored by Rollbar and Hired.
- 48:55Thank you both for supporting the show.
- 48:57Rollbar takes the pain out of errors.
- 49:00They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain, of course.
- 49:07As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com slash Talk Python To Me.
- 49:15Hired wants to help you find your next big thing.
- 49:17Visit Hired.com slash Talk Python To Me to get five or more offers with salary and equity presented right up front
- 49:23and a special listener signing bonus of $2,000.
- 49:26Are you or a colleague trying to learn Python?
- 49:29Have you tried books and videos that just left you bored by covering topics point by point?
- 49:34Well, check out my online course, Python Jumpstart, by building 10 apps at talkpython.fm/course
- 49:40to experience a more engaging way to learn Python.
- 49:42And if you're looking for something a little more advanced, try my WritePythonic code course at talkpython.fm/Pythonic.
- 49:50Be sure to subscribe to the show.
- 49:52Open your favorite podcatcher and search for Python.
- 49:54We should be right at the top.
- 49:55You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 50:05Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
- 50:10Corey just recently started selling his tracks on iTunes, so I recommend you check it out at talkpython.fm/music.
- 50:16You can browse his tracks he has for sale on iTunes and listen to the full-length version of the theme song.
- 50:22This is your host, Michael Kennedy.
- 50:24Thanks so much for listening.
- 50:25I really appreciate it.
- 50:26Smix, let's get out of here.
- 50:28Smix, let's get out of here.
- 50:28Outro Music.
- 50:50you
- 50:50.
- 50:51you