Transcript #253: A new Python for you, and for everyone!
Return to episode page view on github00:00 Hey there, thanks for listening. Before we jump into this episode, I just want to remind you
00:03 that this episode is brought to you by us over at Talk Python Training and Brian through his pytest
00:09 book. So if you want to get hands-on and learn something with Python, be sure to consider our
00:15 courses over at Talk Python Training. Visit them via pythonbytes.fm/courses. And if you're
00:22 looking to do testing and get better with pytest, check out Brian's book at pythonbytes.fm slash
00:27 pytest. Enjoy the episode. Hello and welcome to Python Bytes, where we deliver Python news and
00:33 headlines directly to your earbuds. This is episode 253, recorded October 6th, 2021. I'm Brian Okken.
00:41 I'm Michael Kennedy. Yeah, name's CX. This is me. So welcome. Hey, before we jump into some of our
00:49 topics, could you tell us a little bit about yourself? Sure, of course. First of all, I'm super
00:54 excited to be here. A little bit nervous because it's my first podcast ever. And I'm very happy to
01:02 be on Python Bytes. It's the podcast I've been listening to, I think, for the last five years,
01:08 about the same time I got into Python. So right now, I'm... I started... Like recently, a month ago,
01:17 I started working at a new company, cybersecurity company called Pytho Benito.
01:22 They're doing some cool stuff, automated network perimeter security for Fortune 500 companies. Very
01:32 interesting approach. What I do there is I'm an infrastructure and Intel tools developer and Python,
01:42 of course. And I've been doing Python for the last six years. So as a developer, as a backend developer,
01:50 as an automation developer, I actually started my career as a Q&A engineer. I didn't have any background,
01:58 coding background. So I kind of learned the Python on the job starting from little script snippets. And then I got into
02:05 pytest and automation. And at some point, I just switched to, yeah, full-time developer. But still, like,
02:15 testing is something very precious to me. I'm very invested in it. So, yeah.
02:21 Kind of important to me, too.
02:22 Yeah, I know.
02:23 Yeah, awesome.
02:25 I know.
02:26 I'm out of doing.
02:27 Thank you.
02:28 Welcome.
02:29 Well, Michael, let's kick it off with some awesomeness.
02:31 Yeah, I love awesome things. So let's kick it off with awesome HTMLX.
02:37 So we've covered many awesome lists. And one of the hottest technologies in the Python space these days,
02:45 and at least with the web, is over at htmax.org. A really cool way to basically create apps that you
02:52 would normally create with Vue or React, but just do it all in Python and mostly on the server,
02:56 which is really cool. So let's see. Make sure I get the name right here.
03:01 Rajeshagar. Probably messed it up. Sorry. But put together this list. Thank you for keeping track of
03:08 all the things that are awesome that have to do with HTMLX. So you look down here, there's like
03:14 blog posts, tools, videos, examples. And what's kind of nice about it is it's not just,
03:20 here's a Python list of using this framework, but it's this framework in a lot of different situations
03:26 that might be useful to people. So for example, if you want to know how to use it in Django,
03:31 there's an example, rather a blog post for that. There's one for using Tailwind with Flask. There's
03:38 one for doing it with somewhere in here. I don't see it yet, but there's a Ruby on Rails one.
03:43 There's plugins for HTML. So if you do Craft, which is a CMS, there's Django integration,
03:50 Rails integration, all kinds of stuff. And there's videos. Check out number three here,
03:54 Python bytes, HTMLX, dynamic and live HTML without JavaScript. That's our YouTube live
03:59 stream. And we had, I think that was Hannah Stepnick who was on with us on that episode.
04:03 And so there's some videos you can check out about it. There's also the talk Python episode where I interviewed Carson Gross, the creator. So they're including our stuff,
04:12 which is very much appreciated. But then also a bunch of examples for like Node.js and ASP.NET.
04:17 And oh my gosh, a lisp. A lisp is in there. But yeah, like plenty of Python ones as well.
04:23 Yeah. This is cool. And yeah, I actually gave some try using HTML mix following one of the podcasts I
04:32 listened to. I don't do a lot of front end, but it was really nice to get rid of some ad hoc
04:40 JavaScript stuff I did. It works so well, doesn't it?
04:46 Oh yeah. And I really don't, I really don't enjoy doing JavaScript because I'm not a front-end developer,
04:55 but sometimes I need to provide some kind of a UI interface and then it requires JavaScript. And then
05:01 like, yeah, I usually just take some snippets from Stack Overflow and throw it in there.
05:07 And when I tried HTMLX, it was so much cleaner. I could understand what's going on there. Very, very nice.
05:16 I think I need a sticker for my laptop that says, I really don't enjoy using JavaScript.
05:20 So one thing I would like to throw out there that people, when I, I'm doing a talk in San Francisco and
05:27 people heard the title, which is something like, you know, interactive Python web apps,
05:33 hold the JavaScript, something like that. And they're like, oh, why are you always hating on
05:37 JavaScript? I'm not, I don't think that this is so much about hating on JavaScript. If you want to do
05:42 JavaScript, knock yourself out. You can write, you can like a lot of these examples are node.js and
05:48 express using HTMX. But the three of us on this call, we're not like, I can't wait to run out and
05:53 write stuff that runs on node. We'd much rather go write stuff that runs on Python. So what this lets us
05:59 do is still use like Python code on the server, but then it just behaves as if it was running on the front.
06:07 And it's super smooth. Just like y'all said, like it really cleans things up and makes it simple.
06:11 Yeah. So here's a bunch of awesome stuff.
06:13 It's not just JavaScript. There's a bunch of other languages I don't want to work in either.
06:15 Exactly.
06:17 Awesome. Well, there's not a whole lot more to add to this, but it's nice when these emerging
06:24 technologies are coming along to get some help and examples and other resources. So thanks,
06:30 Rush, for putting together this awesome list.
06:33 Yeah. Well, I can't believe I got this topic. You guys. Yeah. Anyway, Python 3.10,
06:39 I'm so excited. It came out two days ago. I'm loving it. I've switched. I'm using it at work.
06:46 I'm using it at home. And it's not like it's new. I mean, one of the things there was an article.
06:52 I'll just go through a few topics. One, the logo is awesome. 310, the 310 launch logo.
06:57 Super cool. Yeah, I love it. I want a sticker like that. There's a couple of videos that I think are
07:02 good to at least know about. There's the launch party that started off with some awesome hats.
07:11 They basically actually walked through the entire launch process of making 310 live on camera.
07:19 It's three hours long though. I only watched a little bit, but great hats.
07:23 This is cool. Yeah. So this is by the people who are actually releasing. It's not a party celebrating
07:29 the launch. It's the actual launch.
07:31 Yeah, the actual launch. Right. It's awesome.
07:33 It was neat. But chat brains hosted, I think that was a prerecorded thing, but there was a
07:39 what's new in Python 3.10 video that I, this is more, more, more consumable at 33 minutes.
07:49 I, I definitely, I watched this, while it was live or while it was being broadcast at first.
07:55 Yes. A couple of days ago. And it's really interesting. This, this one's really great.
07:59 I thought I knew everything that was coming in 310. The thing that I really love about this video is,
08:04 there's a Ćukasz Langa and, camera or somebody else talked about, do you know,
08:11 the other person was Sebastian Ramirez and Brant Boucher. Okay. and, Lucas,
08:18 talked about some of the, some of the details on, well, a couple of them were talking about the,
08:25 I'm getting this wrong. What's the thing? the structural pattern matching. That's it.
08:30 Yes. super, super switch. Yeah. So is structural pattern matching. It's gonna,
08:35 it's really cool. I haven't come up with a reason to use it yet. but, give me time, but the,
08:42 there was a discussion of why the, like a whole, a big discussion on this, which was neat. It was a kind
08:47 of a tutorial right there. And then also a discussion of why black doesn't work for it
08:53 yet. So that was the odd takeaway that I didn't, wasn't expecting is if you're really addicted to
08:59 black, you can't use structural pattern matching and black together right now. they will catch
09:04 up, but they're, they have two different parsers for Python and getting them all cut up will be,
09:10 it'll take a little time. So be patient. Nice. Yeah. That's huge. But I guess if you want to use,
09:19 the, if you still want to use black, you just need to just, do formatting off on the block when
09:28 you use, pattern matching. So yeah, actually I have to put it in a different file. Cause you can't,
09:33 the format off doesn't work in line in the file with it. I tried that and it didn't work.
09:41 Interesting. It didn't work. Oh, that's a, that's a bummer. Okay.
09:44 But all the other features of three 10 seem to work fine. So it's good. Yeah. Very nice. some of the
09:51 some of the things that jump out that are exciting for me is X pipe Y versus rather than, X,
09:58 you know, union of X comma Y or optional of X versus X comma or X pipe. None. Those, those are nice.
10:07 The additional type information and better error messages. Those are the things that I'm looking
10:11 forward to, except for, I'm not really looking forward to errors. I generally don't like that,
10:15 but once you're there, I prefer better error messages. I think everybody teaching Python is going
10:20 to love the error messages. So. Oh, the, the error messages are pretty awesome. Just a few days ago,
10:26 I was refactoring some code and I had some, well, a bit complex expression. It was like nested deep and
10:33 I needed to do some asserting. And so another parenthesis, and I guess I missed something.
10:39 And then I would have, I had this error, like expression is expected. And we're like, what expression?
10:46 It's all right there. And I wasted literally like about three minutes figuring out what expression
10:52 it's missing. And eventually they end up like, I missed some curly brackets. And I really expect,
10:59 I mean, yeah. Pattern matching is great. The, the pie painting is awesome. But those specific,
11:07 like little things are, I don't know, I think like really bombs your dev experience. So yeah.
11:14 Yeah. It definitely does. Speaking of better error messages and stuff, I'm planning on just integrating
11:20 a rich, like the trace back stuff and all those kinds of things just into all my apps. Cause it's just
11:25 better. And it's one line of code at the top. So very nice. Yeah. That's cool. Yeah. All right. Good one,
11:31 Brian. All right. Yeah. You're up with the next one. Yeah. So it's a tool I've stumbled upon a while
11:39 when I was looking for some kind of a solution for bundling all my, all our analysis tools in one,
11:51 and then we have like large code bases and we use a microservices. So that we have a lot of repositories.
12:00 And of course we would like to use some linking. and then we added pipeline style and then we added
12:07 another package because we found it pretty useful called culture that finds that some unused, the code
12:17 then pointed out that maybe it should be removed or refactor, which is quite cool.
12:21 Vulture. That is a fantastic name for that Lint feature. Yeah.
12:26 It goes in five inch dead code. Oh my gosh.
12:29 Yeah. Yeah. It's pretty cool.
12:31 Okay. Sorry. I just, I love the name.
12:33 Yeah. That's, that's one of the latest additions. And then, well, because we deal with the
12:40 some security and vulnerabilities, we decided also to add bandwidth to the whole party.
12:45 those are really awesome tools, but we started to get a bit frustrated. First of all,
12:51 each and every tool requires a sun configuration file, like profiling, like, every linker has
12:59 its own rules by that style. You want to ignore some stuff. Oh, it's kind of a, kind of a requires customization.
13:05 So we ended up having like four different customization profile files for each tool. And that's okay. I mean,
13:14 once you've done it, it's okay. But then people start to get really frustrated with their FTIs
13:20 because it became a bit slow because of the, all the tools run sequentially. So, and even more so,
13:28 they become a bit frustrated with all the types, all the different outputs. So let's say you have
13:33 issues in piling, and then you have problems with PID code style. And at first, we didn't, we just
13:41 started failing once you, once you have a failure in piling, you don't proceed, but you fix piling. And then,
13:47 oh, okay. Yay. But then you have errors in Python style and so on and so on. So it was really frustrating.
13:53 so we said, okay, just okay. It fails, but let's continue. And then just, speed all the errors once, once it's done.
14:02 So, but still people had some issues and started reading the output because it's different format. And they're like,
14:11 okay, what does it want from me? What, what do I do? And, you know, and then the whole thing, the whole experience is,
14:18 okay, I finished working on my PR. I just want to post it and get a review in it. But then I get stuck in this
14:24 limbo of fixing all this kind of stuff. So we started thinking what can, improve the, user and the
14:32 dev, the dev experience. So people will get frustrated. Yeah. Because people want people to take the
14:37 data. Yeah. They start a disabling creatures and that's something that we didn't want.
14:43 Yeah. Then your CI starts to lose all its value and everything. Right?
14:47 Exactly. Exactly. So I kind of stumbled on a prospector and I, I say stumble because it was,
14:55 was always there. It's actually brought, brought by PySecure, the same, the same guys, the same
15:01 organization that are responsible for piling and for PyCock style. But somehow I missed the
15:07 whole bundle thing that called prospector. I guess it's a bit less popular. So we started using it.
15:14 it bundled all our, analysis tools together in one run and in one unified output. So it's much
15:24 easier when you have the output just, just to read it and understand what's going on. And more than that,
15:33 some bonuses, we discovered some more tools that it provides that we didn't be weren't even familiar
15:39 with such as the McCabe complexity analysis, which, provides, points out some kind of a cop,
15:48 like in case you have a very big, function with nested conditions and stuff.
15:54 Nice. Is that like cyclomatic complexity and stuff like that?
15:57 Exactly. Yeah. So there's actually a link there inside that, takes you to Wikipedia and explains how all those things are calculated, but it's pretty, pretty nice.
16:11 some, you, you cannot always follow it through because sometimes, well, you have a complex function
16:17 in the legacy code and don't necessarily want to mess with it, but it's nice to have this information
16:23 that you can put in a backlog. So that's something we discovered that there's also pyroma if you're developing packages.
16:31 So if you have like some missing, let's say contributor, RFC or, so it will point out all the stuff there.
16:40 you have the dodgy, that points out if you have like some sensitive data such as passwords or like AWS keys or some things you not necessarily want to include in your code way.
16:57 So a lot of goodies that come with this prospector that actually bundles a lot of analysis tools, which is cool.
17:07 But, as I said, for us, it really improve our experience because it's one output and one profile configuration,
17:16 which means instead of having like a configuration file for each of the tools, you have only one to rule them all.
17:24 And more than that, you have profile, which means like, let's say you have, at some point you would like to run my type.
17:33 Okay. But in some point you don't want, like, if you are merging to master, maybe you want to check vulnerabilities at that point, but not on every commit because you're still developing.
17:44 So super useful. And surprisingly, it runs faster than each tool on its own.
17:52 Wow. That is super cool.
17:54 It takes some time. It takes some time. I mean, it's not a super fast because, first of all, it installs all the required tools for just in one bundle.
18:04 And the execution is still the same execution for all the tools, but yeah, it's really simplified thing. So highly recommended.
18:14 Cool. Good recommendation. out in the live stream, Paul Ansel has a question. Not sure if you know the answer.
18:21 Is there a way to add a comment to your code for her example, hash, no prospector to tell it that a given line is actually not a problem, similar to how bandit would disable warnings with hash. No sec.
18:31 so first factor is just a bundle. It's, like behind the scene, it just indicates the same tool. So you would use the same, disable piling or disable pilot style or no key way. So the, the rules there apply to each tool differently.
18:50 Got it. Makes sense. Cool. All right. Am I up next, Brian? yes. I think so. so another topic on rich, I feel like we're always talking about rich now. super fun. I actually just had Will McGugan, who I see out in the audience. Hey, Will, on talk Python. So that was really fun. So here's the thing from Avi Pearl, not Avi Python, but you know, we'll still accept it.
19:16 Just kidding. That's just the last name. Thank you Avi for sending this over and let us know about it. so Kunyan Tran created this cool terminal based visualizer for Panda's data frames. So she's into data science and stuff like that. And like many things that have to do with rich in UI, just having a screen animation is, is really all you need to know whether or not this is useful for you.
19:41 And so you can just go to the website that we'll link to the GitHub repo and it's got an animated GIF right on the front there. Super nice. So just imagine you are in a Jupyter notebook and you went to a data frame, you said DF dot head or tail, something like that. And you get a little table that comes out. Well, here's one with animation and color and all that stuff as a rich table, you know, the rich library generating the table of the data frame right there.
20:07 So if you're creating something in the terminal and you want a nice output for a data frame, it's pretty simple. The code that you got to write is super easy. So for example, you come up with a data frame somehow, and then you just say from rich data frame and import pretty fine. And then just pretty fine your data frame. And that's it done.
20:29 Like, yeah, it's cool, right? You can also apply it to just regular dictionaries and stuff like that. And you can control things like limit the number of rows that come back, how many columns will be shown in case there's a ton.
20:43 You don't want to fill the screen. Of course, you can transform your data frame. But if you just want a quick like, hey, just show me the first few columns, it'll do that. You can either view the head or the tail effectively. You know, if you're going to say, give me 20 columns, there's 2000. Well, I think that by default, it shows the first the head, but you can also show it in reverse and clear the console. So it just fills the screen, things like that. So even control the animation.
21:06 So not a lot to do with this. But if it's useful to you, I think, I mean, like not a lot of gears and ways to use it. But I think if it's useful to you, you'll really find it interesting.
21:16 Yeah, all those pretty colors. I like it.
21:19 Yeah, yeah, yeah. I love the colors. So super cool.
21:23 So Rich has a ton of stuff in it. But I mean, I use the tables like all over the place because it's just the easiest and prettiest way to display a table right now in a CLI application.
21:36 Awesome.
21:36 Like, love it.
21:38 Love it. Love it.
21:38 Raw Inta out in the live stream says, well, Rich for the win once again, looks great for SSH session.
21:43 Yes, it does. And I hadn't really even thought about it for that scenario. But yeah, it definitely does.
21:48 And Jared says to us, Brian and me, I can't thank you enough for all your podcasts as great as they are.
21:56 The video format is even better. Yeah, Jared, thanks for being here. We always love having people on the show.
22:00 It gives us a little bit more interactive aspect for all the people listening afterwards.
22:05 Yeah.
22:06 Have that, Brian?
22:06 Definitely.
22:07 Go for it.
22:08 So, yeah. I'm going to go back to 3.10 for now. So I'm like, one of the things I'm excited about is the union types.
22:17 One of the things that was released is union types so that you can do X or Y. The thing that I really like about this, one of the things is the optional.
22:29 So you can instead of stuff you've got, I don't have an example here, but if you've got a function that takes an integer, but it might default to none, you can now say that the type is int or none, and then assign it the default value of none.
22:47 So it'd be int or none equal none. And that's, and it's really clean. One of the nice things about that is you don't have to import optional from typing. So that's really clean. But I was, I was like bummed because I actually, a lot of the projects I work on, I have to support more than just 3.10. I've got to support 3.7, 3.8.
23:07 What? You haven't already moved to 3.10? You guys are such laggards.
23:10 The stuff that, like, it's my application.
23:13 You've got two days. Come on.
23:15 If you're supporting Python packages, you want to support more than just one version of Python, right? A little bit. I mean, you don't have to.
23:23 No, of course.
23:24 If you want to. And so then I was excited to see that Adam Johnson put out, and I was actually, I want to shout out who told me about this. Oh, I lost it. Somebody else told me about this.
23:37 So sorry. But Adam Johnson wrote an article about type hints, how to upgrade syntax with pi upgrade.
23:44 So Anthony Sotili wrote a pi upgrade tool. And what it'll do is it does a lot of stuff.
23:54 But one of the things it does is it changes this, this union operator or this. Yeah.
23:59 For types. And it includes, what does it include? The from future import annotations that will allow you to use this type, union types and none in everything back to Python 3.7.
24:14 Very nice.
24:16 Supposedly. I haven't tried it on 3.7, but that's the claim.
24:20 So there's a nice article on how to upgrade your syntax.
24:24 This is a tool, like an automatic tool you just run.
24:27 Yeah. It's a pi upgrade.
24:29 Yeah.
24:30 That's cool.
24:31 Very nice.
24:32 Frederick out in the live stream says the union pipe really makes everything a lot less noisy and more readable. Love it.
24:38 Yes.
24:38 What are you going to offer? What are you going to suggest?
24:41 Oh, the next topic, you mean?
24:44 Oh, yeah. Sure.
24:45 Oh, I actually wanted to just say.
24:48 Just a comment on that. I thought you were going to have a comment on that.
24:50 Yeah, I actually have a little comment because I really like the pi upgrade stuff because I kind of feel that lately we have.
24:59 I enjoy type annotations, but like with each version, I mean, have like a little bit of change and then you have to comply to the previous one.
25:10 And then like what I would love to see is like some kind of a convention on how to do type hinting correctly because there are so many versions.
25:21 And well, because I'm a bit lazy, I don't always use type annotations, but I know I should.
25:29 And then I use some kind of what I use the tools like the monkey type and sometimes the pi annotate.
25:36 So they just add type annotations during run time.
25:41 And then it's a kind of a, then I kind of have some kind of a convention there because I feel like with hyper annotation, you can do it in so many ways.
25:55 Yeah, it's a little bit like string formatting.
25:58 Exactly.
25:58 Exactly.
25:58 But eventually we all, I think we can all agree that f-strings is the way to go.
26:03 Right.
26:04 Yes.
26:04 But right now we're kind of in a wild, wild west with cyber annotations because we have those, I think 3.5, 3, 3.3.
26:15 Yeah.
26:15 And then we have something new and then the old becomes obsolete or fraud upon and then, oh, you shouldn't do it like that.
26:28 But what I would like to see, maybe a tool such as the Pi upgrade that will tell me, okay, this is the convention.
26:36 This is how we do.
26:37 You should be doing your type on a type hinting from now on.
26:42 That's a good idea.
26:42 We saw you're doing the old way.
26:43 Here's the new way to that.
26:44 Yeah.
26:45 Yeah.
26:45 And I'm, I'm a bit confused.
26:47 I'm a bit, and I'm lazy and I'm confused.
26:50 Not entirely.
26:52 It's not a built in feature still.
26:54 Like you're using type annotation.
26:56 I see a lot of Python.
26:58 They slow just fluent for them.
27:00 And for me, it's like, okay, I'll write my code and then, okay, I'll start using some type hinting.
27:06 Yeah.
27:07 Sounds good.
27:07 Yeah.
27:08 I think Pi upgrade is the trick.
27:10 So it does do a lot of these, like the going from uppercase list to lowercase list and switching away from optional and things like that.
27:19 I may be running this later today because it looks good.
27:21 Some kind of a type hinting the formatter.
27:26 Just make it like it should be.
27:28 That's what I would like to see.
27:31 Yeah.
27:31 Exactly.
27:32 Brian, you know what time it is?
27:34 Extra time.
27:35 Extra time.
27:37 You got anything you want to put up there?
27:39 Throw out to people?
27:40 Yeah.
27:41 Actually, I don't have any links for it, but I should have had links up.
27:44 But I was, this is hard for me to believe actually.
27:48 But in like 2017, a long time ago, 2017, 2018, I submitted a defect to pytest, the pytest project.
27:58 And then I also wrote up a test to describe the defect, but I didn't know how to fix it.
28:05 So that was my first contribution to pytest is adding test code.
28:09 But this last week, I added two, had two pull requests and they both got accepted and merged.
28:18 So the next version of pytest will actually have my code in it.
28:22 So.
28:22 Super cool.
28:23 Very cool.
28:24 Hey, I just realized we skipped Yael's final thing.
28:27 Oh, right.
28:28 Oh, no.
28:28 Yeah.
28:28 Sorry.
28:29 Yeah.
28:29 Tell us about that before we get to the rest of the extras.
28:31 That's fine.
28:35 So, yeah.
28:35 I feel like you've got these cool ways to like bring together multiple tools.
28:40 Instead of telling people about Bandit, you're like, here's how to use Bandit, all these things.
28:43 Or instead of Black, here's how to like do all these different things.
28:46 Yeah.
28:47 Yeah.
28:47 I kind of like combining things and then make it more general.
28:52 I mean, the Python ecosystem is so rich.
28:57 There are so many things.
28:58 Yeah.
28:59 So it's nice to bring some stuff together, bundled and easy to use.
29:04 So, darker is something also I stumble.
29:09 Well, I was recommended by a friend after I, after describing a problem or my resentment even to Black formatter.
29:20 I know it's not a popular take.
29:23 Maybe I shouldn't say it.
29:25 But until recently, I was quite well.
29:28 It's not that I don't enjoy Black formatting.
29:31 I think it looks great.
29:33 It's more readable.
29:34 It's nice.
29:35 But I had some major issues with, well, with myself and colleagues that we can get sometimes over into the app.
29:43 Like, okay, I start to write some code.
29:46 And I don't know if it's a bug piece or I'm adding some feature.
29:49 And I'm done.
29:50 But then, yay, I want to make it Black because it's cool.
29:54 And then I run Black on the model.
29:57 Or sometimes if I really want to go wild, I'll run it on the entire package.
30:03 And then I submit my PR.
30:06 And my PR, well, it includes the single bug fix or the little line I've added for the functionality or the fixing.
30:16 And then I have, like, one, I don't know, some hundred changed files because I ran Black.
30:24 Or even if it's in the model, like, the whole model looks, like, brand new.
30:28 And then if I have to use such code, I would say, okay, but where do I start?
30:34 Where do I begin?
30:35 Because I don't know what changed my...
30:36 Why are there so many changes, right?
30:38 Yeah.
30:39 And it became a real issue because, on one hand, there are a lot of developers that were really, like, into Black.
30:46 Let's make everything Black.
30:49 Let's make everything beautiful.
30:51 And on the other hand, we would get those huge PRs.
30:55 Like, okay, where do I start?
30:57 Where do I even start?
30:58 So we started restricting Black.
31:01 We said, we, at some point, we, as a group, we decided, okay, no more Black.
31:06 But that was also very frustrating.
31:08 And then I had some talks with a friend of mine.
31:14 I said, okay, you should use Darker.
31:16 And Darker is really tiny.
31:19 It's not a big package.
31:21 very lightweight.
31:23 And what it does, it takes a little bit more conservative approach.
31:30 It doesn't say, okay, just Black everything and have a huge PR.
31:34 It says, okay, you want to have, to convert your code being beautiful and Black.
31:42 But let's make it gradually.
31:43 And then you have, and then you eliminate this huge PR and this huge mess.
31:50 Just change the stuff you need.
31:53 Run the Docker just on the file or even on the entire code.
31:58 And then it will format only the changes you made in the file.
32:03 Okay.
32:04 So here's the pink.
32:05 Let's see.
32:07 Nice example here.
32:10 I love that.
32:11 I love that it's runs on the last Git changes.
32:13 And that it's actually dark.
32:15 It's very simple.
32:17 I can't believe no one thought of it before.
32:20 Like, so simple.
32:21 Because what it does, it just does Git diff, gets the changes.
32:27 And then just runs Black formatting, all those changes.
32:30 And then you have normal looking PR with nice formatting.
32:35 And yeah, you won't get the whole beautiful Black all in one.
32:41 And you'll make it gradually.
32:42 But eventually, I think it's more controlled, more constrained.
32:48 And I think it's better this way.
32:50 And we started using it a couple of months ago.
32:54 And I think it has a good progress.
32:57 And we just integrated it into our pre-commit hooks.
33:00 So it's kind of seamless.
33:02 It's not that you need to remember running Black.
33:04 Of course, you can also integrate it in PyCharm or ES Code.
33:09 I think even Vim for people who are fond of Vim and stuff.
33:14 I think it has some kind of a plugin as well.
33:16 I don't know who would do that.
33:17 Yeah.
33:18 I don't know.
33:18 Who are those people anyways?
33:23 But yeah, so it's simple.
33:25 Yeah.
33:25 It's really nice and made by, I hope I'll get the name right.
33:33 It's anti-cohoila.
33:38 Yes.
33:39 I hope I didn't know the name.
33:40 Yeah, awesome.
33:41 I think this is great.
33:42 Yeah.
33:42 Paul out in the audience has an interesting bit of feedback.
33:45 This would be super helpful if you're starting to enforce code standards on an already existent repo,
33:50 which is the most kind of code you work with.
33:52 So, yeah.
33:53 Yeah.
33:54 If you're starting like new projects, so yeah, black it all the way.
33:58 That's fine.
34:00 Yeah.
34:01 I've heard recommendations before to just have one commit that just does the black thing.
34:08 But one of the problems with that is you lose sort of the history of when the file really was last modified.
34:14 So if a file hasn't been touched in two years, it's kind of nice to leave it as not touched for two years so that you can kind of see the history.
34:24 Yeah.
34:24 Yeah.
34:25 For sure.
34:26 Yeah.
34:26 If you run black on a five-year-old call base, it would look like you did it all from the beginning.
34:34 On the other hand, if you want to up your commit status, number of lines changed way more than the rest of the team.
34:40 You can always do that.
34:41 Yeah.
34:42 Yeah.
34:42 You could.
34:43 All right.
34:45 I know, Yael, you have a couple of things that you want to give a shout out to at the end here as well.
34:49 So let's just keep going with those.
34:51 Yeah.
34:51 Sure.
34:52 So I have two things.
34:55 The first one is actually a colleague of mine.
34:58 And he's been writing a book, a very interesting book, a bit of a controversial book if you dive into it.
35:07 And he basically says object-oriented, it's good for some, but in general, when you deal with complex problems, the object-oriented programming might even make stuff a lot more complicated in terms of debugging, in terms of separation of concerns.
35:32 And then he presents some kind of a new way to deal with the data and how we process data.
35:42 So it's data-oriented programming.
35:46 I have to admit, I read some of the chapters, not all.
35:52 I didn't finish the book.
35:53 It's almost still a work in progress, but most of it's a bit.
35:57 But you don't have to agree on everything, but the whole approach is the combination of data-oriented programming with functional programming.
36:09 I think there's some benefits to it.
36:12 And some complex problems can be solved faster and easier and with less debugging strength.
36:20 Like for me, like I have this rule of thumb that if I have to activate debugger over and over again to understand what the code does, instead of just reading the code, it means that something with the code is not 100% right.
36:39 Okay.
36:40 Because the code should be readable.
36:42 And I encountered those issues when working with very heavy object-oriented code bases.
36:49 Like a lot of inheritance and multi-inheritance.
36:52 And then I went to Django and they used mixing.
36:55 It is hard.
36:57 It is hard to design.
36:59 It is hard to...
37:01 But mostly it is hard to read.
37:04 And this approach, it's interesting.
37:06 As I said, I'm not fully, like, I'm not fully agree that, okay, object-oriented should be gone from the world.
37:14 It's not my stand, but I think...
37:17 Some people have made that stand, but it still is around, isn't it?
37:20 Yeah, but I'm not completely on board with that.
37:26 But I think in some cases, there are approaches that are much more lightweight.
37:32 And the whole thing with data versus code separation, I think it's nice.
37:39 I think it's kind of...
37:41 Nice.
37:42 Yeah, it kind of rewires your brain a bit after you read the chapter or two.
37:47 Like, makes you...
37:48 Yeah, maybe it's one of those things like functional programming.
37:51 You don't necessarily do it all the time, but you read it and it gives you a different perspective, even if you don't totally adopt it.
37:56 Yeah, exactly.
37:57 That's a good thing.
37:57 Yeah.
37:58 Okay.
37:59 All right.
37:59 And a little bit self-promotion here.
38:03 So a few months ago, I released my first open source project, Cornell.
38:10 It was actually covered by Brian, I think, two months ago.
38:16 Yeah.
38:17 Yeah.
38:17 So I just wanted to do a little shout out to all developers out there who are looking to contribute to a little bit nice, with a very nice documentation project.
38:31 It's only the beginning.
38:33 What it does is that it's actually a record and a replay server for mock.
38:41 It's a mock server that we call real data and then can be used as part of the CI and for purposes for end-to-end testing.
38:53 Because if you have some kind of an entry point that starts a cascade of events, including salary or whatever, and just eventually you reach the part when you go out and send an HTTP request.
39:09 So here Cornell comes in handy.
39:12 We use it quite a lot.
39:14 I'm in my previous company and I'm trying to now integrate it in my current workplace and I think it has some potential.
39:24 Very cool.
39:25 And it's not very mature.
39:27 So I would love, like really, if someone wants to contribute even a title or documentation or whatever, we really warmly welcome all contributions.
39:38 So it's great.
39:39 Yeah, that's great.
39:40 Brian asked me on that episode where I thought the name came from.
39:44 And I thought Chris Cornell from Soundgarden and all that.
39:47 Is that correct?
39:48 Blackwell Sun and all those things.
39:50 Well, you see the face.
39:52 What the face reminds you of.
39:54 Yeah, it does.
39:55 I don't think I saw that, paid attention to that before.
39:58 But yeah, now that I see it, I'm more confident in my answer.
40:01 Yeah, you are correct.
40:03 Indeed.
40:04 Right on.
40:05 Right on.
40:06 All right.
40:07 Well, I got a few more extras to share with the world.
40:09 Let's see.
40:10 I just like literally at midnight last night, released a new course, HTML plus Flass, modern web apps, hold the JavaScript.
40:17 So this is a three hour course that like dives into cool ways of putting HTML and Flass together.
40:25 And it also brings together some of the other things we've talked about on the podcast before.
40:29 So when I was creating this course, I didn't really like the way that you would reuse HTML.
40:34 I have a lot of duplication and other crummy stuff.
40:36 So I created the Jinja partials and Chameleon partials projects to make this code better.
40:41 But anyone who uses HTML with Jinja or Chameleon should definitely check those out.
40:46 That's covered in the course.
40:47 There's also just links to it.
40:48 Of course, it does cost money, but you can go and get the GitHub repo and check out the stuff there.
40:53 So that's really cool.
40:54 Build like a really fun little app there and add a bunch of HTML things to it.
40:58 So link in the show notes.
40:59 Check that out.
41:00 Yeah.
41:01 So we've got an update, an update from Dan.
41:04 So, Brian, did you cover this?
41:06 I covered this last time, I think.
41:07 Thanks.
41:08 But the update is, yeah, we were talking about having, so it'll go and do auto optional stuff
41:15 where if you say something is like x:nt equals none as a default value, it goes,
41:22 no, no, no, no, no, that doesn't make sense.
41:23 So it'll create an optional of int automatically and correct the typing.
41:29 But we made the comment, Brian, I think maybe you did.
41:31 I can't remember who, but said, oh, it'd be really cool if we could use the pipe syntax
41:35 that we just talked about earlier.
41:36 So auto optional has been updated to create x:pipeNone instead of optional of x, which is
41:42 really cool.
41:43 Yeah.
41:44 I love it.
41:45 I love how the podcast helps bring some of this feedback to the world.
41:48 Change the world.
41:49 That's right.
41:50 We have made a dent in the universe, Brian, and it is x:pipeNone.
41:53 Okay.
41:54 Coverage, Ned Batchelder just released coverage on Monday.
41:58 So coverage six, which is a major reason.
42:01 Python 2 has been expelled from coverage, which is all good.
42:05 And 30 third-party packages are automatically ignored, which could be a big change for some people.
42:10 All right.
42:11 Bunch of other stuff.
42:12 You can check it out if you care a lot.
42:13 Django328 is out with a couple of bug fixes about read-only fields and admin and some regression
42:19 bug going on.
42:20 So check that out as well.
42:22 Sweet.
42:23 Yep.
42:24 Well, I guess this might be a time for a joke.
42:26 Shall we finish it with a joke?
42:27 Yes.
42:28 As we often do.
42:29 All right.
42:30 Going back to the very reliable geek and poke here.
42:33 We have paired captcha, as in reCaptcha.
42:36 You know, the little pop-up.
42:38 Oh.
42:39 You get the different panels.
42:40 You've got to say, like, click all of the crosswalks or click all of the dogs or whatever.
42:46 All right, Brian.
42:47 Let's do this together like last time.
42:51 I'll do the first one, the woman developer or just computer user trying to get through this.
42:57 So is this a traffic light or just a light?
43:01 No idea.
43:02 I guess it would guess a traffic light.
43:05 Nope.
43:06 Does the gray pixel in the corner also belong to the street sign?
43:12 And on and on it goes.
43:14 It's a sad statement on our digital existence.
43:20 There's been some where I'm stumped.
43:22 I'm like, I don't know.
43:24 I know.
43:25 Next.
43:26 Next question, please.
43:27 Sometimes I just troll three times in a row.
43:32 It's so embarrassing.
43:33 Am I a machine?
43:35 I couldn't find all the mountains.
43:40 Yeah.
43:40 The worst is when you find all the stuff correctly, then it refreshes and go find some mountains.
43:43 And you're like, I just found them all.
43:45 Why are you doing this to me?
43:47 You seem like you like to find traffic lights.
43:50 Here, have some more.
43:51 You looked bored.
43:53 We got some more lights for you.
43:55 Yeah.
43:56 All right.
43:57 Well, that's the joke I brought for y'all.
43:59 Well, thanks.
44:00 And I appreciate you finding them.
44:02 That's cool.
44:03 Cool.
44:04 So thanks a lot, everybody.
44:05 And we'll wrap it up for today.
44:07 And thanks, everybody on the stream for joining us.
44:10 We really appreciate it.
44:11 Yeah.
44:11 Thanks.
44:12 Y'all, thank you especially for being here.
44:14 Yeah.
44:15 It was really fun.
44:15 Thank you.
44:15 Thanks for listening to Python Bytes.
44:17 Thanks for listening to Python Bytes.
44:19 Follow the show on Twitter via @pythonbytes.
44:22 That's Python Bytes as in B-Y-T-E-S.
44:25 Get the full show notes over at pythonbytes.fm.
44:28 If you have a news item we should cover, just visit pythonbytes.fm and click submit in the
44:33 nav bar.
44:34 We're always on the lookout for sharing something cool.
44:36 If you want to join us for the live recording, just visit the website and click live stream
44:40 to get notified of when our next episode goes live.
44:43 That's usually happening at noon Pacific on Wednesdays over at YouTube.
44:48 On behalf of myself and Brian Okken, this is Michael Kennedy.
44:52 Thank you for listening and sharing this podcast with your friends and colleagues.