Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #253: A new Python for you, and for everyone!

Return to episode page view on github
Recorded on Wednesday, Oct 6, 2021.

00:00 Hey there, thanks for listening.

00:01 Before we jump into this episode, I just want to remind you that this episode is brought to you by us over at Talk Python Training, and Brian through his pytest book.

00:10 So if you want to get hands on and learn something with Python, be sure to consider our courses over at Talk Python Training.

00:17 Visit them via pythonbytes.fm/courses.

00:21 And if you're looking to do testing and get better with pytest, check out Brian's book at pythonbytes.fm/pytest.

00:29 Enjoy the episode.

00:30 Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.

00:36 This is episode 253, recorded October 6, 2021.

00:40 I'm Brian Okken.

00:41 I'm Michael Kennedy.

00:42 Yeah, my name is Fiat.

00:43 This is me.

00:44 So welcome.

00:45 Hey, before we jump into some of our topics, could you tell us a little bit about yourself?

00:52 Sure, of course.

00:53 First of all, I'm super excited to be here.

00:56 a little bit nervous because it's my first podcast ever and I'm very happy to be on Python Bytes.

01:04 It's the podcast I've been listening to, I think, for the last five years, about the same time I got into Python. So right now I'm, I started like recently a month ago, I started working at a new company, cybersecurity company called Python Benito. They're doing some cool stuff automated network perimeter security for fortune 500 companies. Very interesting approach. What I do there is I'm an infrastructure and intel tools developer and Python, of course.

01:43 And I've been doing Python for the last six years. So as a developer, as a back-end developer, an automation developer. I actually started my career as a QA engineer. I didn't have any background coding background, so I kind of learned the Python on the job starting from little script and snippets and then I got into pytest and automation and at some point I just switched to, yeah, full-time developer but still like testing is something very precious for me.

02:18 I'm very invested in it.

02:20 So yeah, kind of important to me too.

02:22 Yeah, I know.

02:23 I know.

02:25 I have a lot of feeling.

02:28 Thank you.

02:28 Well, Michael, let's kick it off with some awesomeness.

02:31 Yeah, I love awesome things.

02:34 So let's kick it off with awesome htmx.

02:37 So we've covered many awesome lists and one of the hottest technologies in the Python space these days and at least with the web is over at htmx.org, a really cool way to basically create apps that you would normally create with Vue or React, but just do it all in Python and mostly on the server, which is really cool.

02:57 So let's see, make sure I get the name right here.

03:01 Rageshagar, probably messed it up, sorry, but put together this list, thank you, for keeping track of all the things that are awesome that have to do with HTMX.

03:12 So you look down here, there's like blog posts, tools, videos, examples.

03:18 And what's kind of nice about it is it's not just, here's a Python list of using this framework, but it's this framework in a lot of different situations that might be useful to people.

03:28 So for example, you wanna know how to use it in Django, there's an example, or rather a blog post for that.

03:34 There's one for using Tailwind with Flask.

03:37 There's one for doing it with somewhere in here, I don't see it yet, but there's a Ruby on Rails one.

03:44 There's plugins for HTMS.

03:46 Like, so if you do craft, which is a CMS, there's Django integration, Rails integration, all kinds of stuff.

03:53 And there's videos, check out number three here, Python Bytes, HTMX, Dynamic and Live HTML without JavaScript.

03:58 That's our YouTube live stream.

04:00 And we had, I think that was Hannah Stepnik, who was on with us on that episode.

04:04 And so there's some videos you can check out about it.

04:06 There's also the Talk Python episode where I interviewed Carson Gross, the creator.

04:10 So they're including our stuff, which is very much appreciated, but then also a bunch of examples for like node.js and ASP.net and oh my gosh, Elisp.

04:19 Elisp is in there, but yeah, like plenty of Python ones as well.

04:22 Yeah.

04:23 This is cool. And yeah, I actually gave some try using HTML mix following one of the podcasts I listened to.

04:33 I don't do a lot of frontend, but it was really nice to get rid of some ad hoc JavaScript stuff I did, you know, just to work so well, doesn't it?

04:46 Oh yeah.

04:47 And I, I really don't, I really don't enjoy doing JavaScript because I'm not a front-end developer, but sometimes I need to provide some kind of a UI interface and then it requires Java, JavaScript.

05:01 And then I usually just take some snippets from Stack Overflow and throw it in there.

05:08 And when I tried HTMX, it was so much cleaner.

05:13 I could understand what's going on there.

05:15 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 people, heard the title, which is something like, you know, interactive Python, web apps, hold the JavaScript, something like that.

05:34 And they're like, Oh, why are you always hitting on JavaScript?

05:38 I don't think that this is so much about hating on JavaScript.

05:41 If you want to do JavaScript, knock yourself out.

05:44 You can write, you can, like a lot of these examples are Node.js and Express using HTMX.

05:50 But the three of us on this call, we're not like, I can't wait to run out and write stuff that runs on Node. We'd much rather go write stuff that runs on Python.

05:57 So what this lets us do is still use like Python code on the server, but then it just behaves as if it was running on the front end.

06:07 It's super smooth, just like y'all said.

06:09 Like it really cleans things up and makes it simple.

06:11 - Yeah.

06:12 - 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 wanna work in either.

06:16 (laughing)

06:17 - Exactly.

06:18 (laughing)

06:20 Awesome.

06:21 Well, there's not a whole lot more to add to this, but it's nice when these emerging technologies are coming along to get some help and examples and other resources.

06:29 So thanks, Raj, for putting together this awesome list.

06:33 - Yeah.

06:34 Well, I can't believe I got this topic.

06:36 You guys, yeah, anyway, Python 3.10, so excited.

06:40 It came out two days ago.

06:42 I'm loving it.

06:44 I've switched.

06:45 I'm using it at work.

06:46 I'm using it at home.

06:48 And it's not like it's new.

06:49 I mean, one of the things, there was an article, okay, I'll just go through a few topics.

06:54 One, the logo's awesome.

06:55 3.10, the 3.10 launch logo, super cool.

06:59 I want a sticker like that.

07:00 There's a couple of videos that I think are good to at least know about.

07:04 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:18 It's three hours long though.

07:21 I only watched a little bit, but great hats.

07:24 - This is cool.

07:24 Yeah, so this is by the people who are actually releasing.

07:27 It's not a party celebrating the launch.

07:30 It's the actual launch.

07:32 - The actual launch.

07:33 >> Right, that's awesome.

07:34 >> But Jeff Brains hosted, I think that was a pre-recorded thing, but there was a What's New in Python 3.10 video.

07:43 This is more consumable at 33 minutes.

07:49 I watched this while it was live or while it was being broadcast at first just a couple of days ago.

07:56 It's really interesting.

07:58 This one's really great.

07:59 I thought I knew everything that was coming in 3.10.

08:02 The thing that I really love about this video is there's Lucas Lange and I can't remember somebody else talked about, do you know the other person was?

08:12 Sebastian Ramirez and Brant Boucher.

08:15 Okay, and Lucas talked about some of the details on, well a couple of them were talking about the I'm getting this wrong, what's the thing? The structural pattern matching, that's it.

08:30 Yes, super switch.

08:32 >> Yeah. Is structural pattern matching?

08:35 It's really cool.

08:37 I haven't come up with a reason to use it yet, but give me time.

08:41 But there was a big discussion on this, which was neat.

08:47 It was a tutorial right there.

08:49 Then also a discussion of why black doesn't work for it yet.

08:54 That was the odd takeaway that I wasn't expecting is, if you're really addicted to black, You can't use structural pattern matching and black together right now they will catch up but they're they have two different parsers for python and getting them all cut up will be it'll take a little time. So be patient nice Yeah, that yeah, that's huge but I guess if you want to use the If you still want to use black you just need to just do formatting off on the block when you use - Yeah, actually I have to put it in a different file 'cause you can't, the format off doesn't work in the file with it.

09:38 I tried that and--

09:40 - And it didn't work, interesting.

09:42 - Didn't work.

09:43 - Oh, that's a bummer, okay.

09:45 - But all the other features of 310 seem to work fine.

09:49 So it's good.

09:50 - Yeah, very nice.

09:51 Some of the things that jump out that are exciting for me is X pipe Y versus, rather than X union Y, you know, union of X comma Y or optional of X versus X comma or X pipe none.

10:06 Those, those are nice.

10:07 The additional type information and better error messages.

10:10 Those are the things that I'm looking forward to, except for I'm not really looking forward to errors.

10:13 I generally don't like that, but once you're there, I prefer better error messages.

10:18 I think everybody teaching Python is going to love the error messages.

10:21 Oh, the error messages are pretty awesome.

10:24 just a few days ago, I was refactoring some code and I had some, well, a bit complex expression that was like nested deep and I needed to do some asserting.

10:35 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 it's all right there.

10:47 And I wasted literally like about three minutes figuring out what expression it's missing and eventually they end up like I missed some curly brackets and I really expect, I mean, yeah, pattern matching is great.

11:02 The pie painting is awesome.

11:05 And, but those specific like little things are, I don't know, I think like really bumps your dev experience.

11:13 So yeah.

11:14 Yeah, it definitely does.

11:16 Speaking of better error messages and stuff, I'm planning to just integrating of rich, like the trace back stuff and all those kinds of things just into all my apps, cause it's just better.

11:26 And it's one line of code at the top.

11:27 So very nice.

11:28 Yeah, that's cool.

11:29 Yeah.

11:30 All right.

11:30 Good one, Brian.

11:31 All right.

11:31 Y'all you're up with the next one.

11:33 Yeah.

11:34 So it's a tool I've stumbled upon a while ago.

11:40 when I was looking for some kind of a solution for, bundling all my, and all our analysis tools under one umbrella.

11:52 So we have large code bases and we use microservices, so we have a lot of repositories, and of course we would like to use some linking.

12:04 And then we added PythonStyle.

12:06 And then we added another package, because we found it pretty useful, called Vulture, that finds that some unused code and points it out that maybe it should be removed or refactored, which is quite cool. That is a fantastic name for that Lint feature. It goes in Fison's dead code.

12:28 Oh my gosh. Yeah, it's pretty cool. Sorry, I just, I love the name. Yeah, that's one of the latest edition. And then, because we deal with some security and vulnerabilities, we decided also to add bandwidth to the whole party. Those are really awesome tools, but we started to get a bit frustrated. First of all, each and every tool requires its own configuration file, like profiling, like every linker has its own rules by that style. You want to ignore some stuff, which kind of Requires customization. So we ended up having like four different customization Profile files for each tool and that's okay. I mean once you've done it, it's okay But then people start to get really frustrated with their fci Because it became a big flow because of the all the tools run sequentially. So And even more so they become a bit frustrated with all the types all the different outputs So let's say you have issues in filings and then you have problems with Pycode style and at first We didn't We just started failing once you once you have a failure in filing you don't proceed so you fix filings and then Okay, yay, but then you have errors in Python style and so on and so on so it was really frustrating so we said, okay just okay it fails, but let's continue and then just speed all the errors once once it's done But still people had some issues and started reading the output because it's a different format and they're like, "Okay, what does it want from me?

14:12 What do I do?" And the whole experience is, "Okay, I finish working on my PR.

14:19 I just want to post it and get a review on it, but then I get stuck in this limbo fixing all this kind of stuff." So we started thinking what can improve the user and the dev experience.

14:33 So people will get frustrated with CI because people want people to protect the CI, they start disabling features and that's something that we didn't want.

14:42 Then your CI starts to lose all its value and everything, right?

14:46 Exactly.

14:47 Exactly.

14:48 So I kind of stumbled on a prospector and I say stumble because it was always there.

14:56 It's actually brought by PySQL, the same guide, the same organization that are responsible for PyLink and for PyProp style.

15:05 But somehow I missed the whole bundle thing that's called Perfector.

15:10 I guess it's a bit less popular.

15:12 So we started using it.

15:14 It bundled all our analysis tools together in one run and in one unified output.

15:23 So it's much easier when you have the output just to read it and understand what's going on.

15:30 And more than that, some bonuses, we discovered some more tools that it provides that we weren't even familiar with, such as the McCabe Complexity Analysis, which points out some kind of a, of a cop, like in case you have a very big, function with nested conditions of stuff.

15:54 Nice.

15:54 Is that like cyclomatic complexity and stuff like that?

15:57 Exactly.

15:58 Yes.

15:59 So there's actually a link there inside that takes you to Wikipedia and explains how all things, all those things are calculated, but it's pretty, pretty nice.

16:11 some, you cannot always follow its rule because sometimes, well, you have a complex function. It's a legacy code and you don't necessarily want to mess with it.

16:21 But it's nice to have this information or you can put it in a backlog. So that's something we discovered. There's also Pyroma if you're developing packages. So if you have some missing, let's say, contributor RFC, so it will point out all the stuff there. You have the dodgy package that points out if you have some sensitive data, such as passwords or AWS keys or some things you not necessarily want to include in your code base. So a lot of the goodies that come with this perspective is that it actually bundles a lot of analysis tools, which is cool.

17:07 But as I said for us it really improved our experience because it's one output and one profile configuration which means instead of having like A configuration file for each of the tools you have only one tool demo 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 Okay, but in some point you don't want like if you are merging to master maybe you want to check for vulnerabilities At that point but not on every commit because you're still developing so super useful and surprisingly It runs faster than each tool on its own. I mean It takes it takes some time. It takes some time I mean, it's not a super fast because that first of all it installs all the required tools, but that's been one bundle and the execution is still the frame execution for all the tools.

18:09 But yeah, it's really simplified thing.

18:12 So highly recommended.

18:14 Cool.

18:15 Good recommendation.

18:16 out in the live stream, Paul Anzal has a question.

18:20 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.

18:27 Similar to how bandit would disable warnings with hash no sec.

18:31 so prospector is just a bundle.

18:35 It's, like behind the scene, it just ends up the, the same tool.

18:39 So you use the same, the shable piling or disabled package file or no QA.

18:46 So the, the rules there apply to each tool differently.

18:50 Got it.

18:51 Makes sense.

18:51 All right.

18:54 Am I up next, Brian?

18:54 yeah, I think so.

18:57 so another topic on rich.

19:00 I feel like we're always talking about rich now.

19:03 Super fun.

19:04 I actually just had Will McGugan, who I see out in the audience.

19:07 Hey, Will, on Talk Python.

19:10 So that was really fun.

19:10 So here's a 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.

19:18 Thank you, Avi, for sending this over and let us know about it.

19:21 So, Junyun Tran created this cool terminal-based visualizer for Pandas DataFrames.

19:30 So she's into data science and stuff like that.

19:32 And like many things that have to do with rich in UI, just having a screen animation 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.

19:48 Super nice.

19:49 So just imagine you are in a Jupyter notebook and you went to a data frame, you said df.head or tail, something like that, and you get a little table that comes out.

19:57 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:08 So if you're creating something in the terminal and you want a nice output for a data frame, it's pretty simple.

20:14 The code that you got to write is super easy.

20:16 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 prettyfy your data frame and that's it.

20:28 Done.

20:29 >> Like it.

20:30 >> Yeah, it's cool, right? You can also apply it to just regular dictionaries and stuff like that.

20:35 You can control things like limit the number of rows that come back, how many columns will be shown in case there's a time.

20:42 You don't want to fill the screen.

20:44 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.

20:53 If you're going to say, give me 20 columns, there's 2000.

20:56 Well, I think that by default it shows the first, the head, but you can also show it in reverse.

21:01 And clear the console so it just fills the screen, things like that.

21:04 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.

21:21 >> So super cool.

21:23 >> So Rich has a ton of stuff in it, but I use the tables 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:37 >> I love it.

21:38 >> Love it. Raw Intel out in the live stream says, "Well, Rich for the win once again, looks great for SSH session." Yes, it does, and I hadn't really even thought about it for that scenario, but yeah, it definitely does.

21:48 - Yeah, definitely.

21:49 - 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.

21:59 We always love having people on the show.

22:01 It gives us a little bit more interactive aspects for all the people listening afterwards.

22:05 - Yeah.

22:06 - With that, Brian, go for it.

22:08 - So yeah, I'm gonna go back to 310 for now.

22:13 So I'm like, one of the things I'm excited about the union types like you said for 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 so you can instead of if 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 It'd be int or none equal none.

22:50 It's really clean. One of the nice things about that is you don't have to import optional from typing.

22:57 That's really clean. But I was bummed because actually a lot of the projects I work on, I have to support more than just 3.10.

23:05 I've got to support 3.7, 3.8.

23:07 >> What? You haven't already moved to 3.10?

23:09 You guys are such laggards.

23:11 The stuff that like it's my application, but for two days, if you're supporting Python packages, you want to support more than just one version of Python, right? A little bit.

23:21 I mean, you don't have to.

23:23 No, of course, if you want to.

23:25 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.

23:34 I lost it.

23:36 Somebody else told me about this.

23:37 So sorry, but Adam Johnson wrote an article about type hints, how to upgrade syntax with PyUpgrade.

23:44 So Anthony Sotile wrote a PyUpgrade tool.

23:51 What it'll do is, it does a lot of stuff, but one of the things it does is it changes this union operator for types.

24:00 It includes the from future import annotations that will allow you to use this union types and none in everything back to Python 3.7.

24:15 >> Very nice.

24:16 >> Supposedly. I haven't tried it on 3.7, but that's the claim.

24:20 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 PyUpgrade.

24:30 >> Very nice. Frederick out in the live stream says, The union pipe really makes everything a lot less noisy and more readable.

24:37 Love it.

24:38 Yeah.

24:38 Yeah.

24:38 What are you going to offer?

24:39 What are you going to suggest?

24:40 like, Oh, the next topic, you mean?

24:44 Oh yeah, sure.

24:46 I actually wanted to comment on that.

24:49 I thought you were going to have a comment on that.

24:50 I actually have a little comment because I really liked the, by upgrades stuff because it kind of feel that lately we have, I enjoyed type annotations, but like with each version, let me 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 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, I use the tools like the monkey pipe and sometimes the pie on the fake, so they just add the type on the station during run time.

25:41 and then I, then it's a kind of a, I, I, then I kind of have some kind of a convention there because I feel like with hyper-location you can do it in so many ways, so maybe the string formatting.

25:58 Exactly, but eventually we all I think we can all agree that f strings is the way to go, right?

26:04 But right now we're kind of in a wild wild west with five of the stations because we have those 3.5 at 3 And but they'll but they're evolving like each new item version and have something new and then the old becomes obsolete or a fraud upon and then you know, you shouldn't do it like that, but what I would like to see Maybe a tool such as that I operate that will tell me okay. This is the convention. This is how we do You shouldn't be doing your type on a type hinting from now on. It's a good idea. We saw you're doing the old way Here's the new way to that. Yeah. Yeah, I'm a bit confused And I'm lazy and I'm confused Not entirely. It's not a built-in feature. Still like you're using type annotation I see a lot of Python is so just wait going for them and for me like, okay I'll write my code and then okay, I'll start using some type painting. Yeah, sounds good Yeah I think pay upgrade is the trick 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 So I may be running this later today.

27:21 Does it look good?

27:21 Some kind of a type on the type hinting that formatter, that's naked like it should be.

27:28 That's what I would like to see.

27:31 Yeah, exactly.

27:32 Brian, you know what time it is?

27:34 Extra time, extra time.

27:37 You got anything you want to put up there throughout the people?

27:40 yeah, actually I don't have any links for it, but, I should have had links But I was, this is hard for me to believe actually, but in like 2017, a long time ago, 2017, 2018, I submitted a defect to pytest, the pytest project, 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:21 So it's kind of fun.

28:23 Super cool. Hey, I just realized we skipped Yael's final thing.

28:27 Oh, right.

28:28 Sorry, tell us about that before we get to the rest of the extras.

28:31 That's fine.

28:33 I feel like you've got these, these, these cool ways to like bring together multiple tools instead of telling people about bandit, you're like, here's how to use bandit, all these things are 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 stumbled.

29:09 Well, I was recommended by a friend after I, after describing, a problem or my resentment even to black formatter.

29:19 I know it's not a popular, popularity.

29:23 maybe I shouldn't say it, but until recently I was quite well.

29:29 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've started to write some code and I don't know, it's a bug feature, I'm adding some feature and I'm done, but then, yay, I want to make it black because it's cool.

29:55 And then I run black on the model or sometimes if I really want to go wild I'll run it on the entire package and then I submit my PR and my PR well, it includes the single bug fix or the little line i've added for the functionality or the fixing and then I have like one, I don't know, some hundred changed files because I ran black 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.

30:36 Right.

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 was really like into black, let's everything, let's make everything black.

30:49 like, let's make everything beautiful.

30:51 And on the other hand, we would get those huge PRs, like, okay, well, do I start?

30:57 Where do I even start?

30:58 So we started restricting black.

31:01 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 and said, okay, and you should use darker.

31:16 And the Docker is really tiny. It's not a big package. It's very lightweight.

31:23 And what it does, it takes a little bit more conservative approach.

31:29 It doesn't say, "Okay, just black everything and have a huge PR." It says, "Okay, you want to convert your code being beautiful and black, But let's make it gradually and then you have And then you eliminate this huge pr and this huge mess just to change the stuff you need run meridalka Just on the file or even on the entire code And then it will format only the changes you made in the file. Okay, so here's I think See Nice example here I love that it runs on the last git changes and that it's actually that it's it's very simple I I can't believe no one thought of it for like So simple because what it does is just that was a git diff Gets the changes and then just runs black formatting all those changes and then you have a normal looking pr With with nice formatting And yeah, you won't get the whole beautiful black all in one and you'll make it gradually but Eventually, I think it's more control more more constrained and I think it's better this way and we started using it a couple of months ago and I think It has a good progress when we just integrated it into our pre-commit hooks. So it's kind of seamless It's not that you need to remember running black. Of course, you can also integrate it in by charm Oh, yes, oh, I think you know even been for people who are fond of being myself I think it has some kind of a plug-in. I don't know who would do that Yeah Who are those people?

33:20 anyways But yeah, so it's simple yeah, it's nice and made by Opal it's the main ride. It's Auntie. Auntie. Co. Co. Co. Co. Yes.

33:39 But I think this is great. 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, which is most kind of code.

33:52 He works. So, yeah. Yeah. If you're starting like new project. So yeah. Black it all the way. That's fine.

34:00 But yeah, you're showing recommendations. I've heard recommendations before to just have one commit that just does the black thing But one of the problems with that is you lose sort of the history of when the file really was last modified 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 Um so that you can you know kind of see the history, but yeah Yeah, because if you will, yeah, if you'll run black and on a five year old kit call base, it would look, 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 All right.

34:45 I know y'all, 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, sure.

34:52 So I have to think the first one is actually a colleague of mine and he's been writing a book, a very interesting book, a bit of a controversial book if you dive into it.

35:06 He basically says that 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 the separation of concerns.

35:32 And then we present some kind of a new way to deal with the data and how we process data, 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 still, it's almost still a work in progress, but most of it's a bit broad.

35:57 And you don't have to agree on everything, but the whole approach is the combination of data-oriented programming with functional programming.

36:10 I think there are some benefits to it and then some complex problems can be solved faster and easier and with less debugging strain.

36:20 And 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, because the code should be readable and I encountered those issues when working with very heavy object-oriented code bases Like a lot of inheritance and multi inheritance and then I went to django and they use mixins It is hard. It is hard to design it is hard to But mostly it is hard to read and this approach. It's interesting as I said, I'm not fully Like, I'm not belittling 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, but I think in some cases, there are approaches that are much more lightweight in the whole thing with data versus cold separation, I think it's, yeah, I think it's nice.

37:39 I think it's, and it's kind of, yeah, it's kind of change, rewires your brain a bit after you read the chapter or two, like next year.

37:48 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 Yeah.

37:58 Okay.

37:59 And, oh yeah, a little bit.

38:02 So a few months ago I released my first open source project.

38:07 The Cornell was actually covered by Brian.

38:11 I think two months ago.

38:14 Yeah.

38:14 Yeah.

38:15 So I just thought that to do a little shout out to all the developers out there who are looking to contribute to a little bit nice with a very nice a little bit nice with a very nice documentation project. It's only the beginning. What it does is that it's actually a record and replay server for mock. It's a mock server that we call the real data and then can be used as part of the CI and for purposes for end-to-end testing because like if you have some kind of an entry point that starts a cascade of events including celery or whatever and just then that eventually you reach the part when you Go out and send an HTTP request. So here cornell comes in handy. We use it quite a lot. Um my previous company and I'm trying to now integrate it in my current, work place and I think it has some potential and I will, and it's, 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.

39:39 Yeah, that's great.

39:40 Brian asked me on that episode of where I thought the name came from.

39:44 And I thought Chris Cornell from Soundgarden and all that is, is that correct?

39:49 Black hole sun and all those things.

39:50 Well, you see the face, what the face reminds you of.

39:54 Yeah, it does.

39:56 No, I didn't.

39:56 I don't think I saw that, paid attention to that before, but yeah, now that I see it, I'm more confident in my answer.

40:02 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 had just like literally midnight last night, released a new course, HTMX plus Flask, Modern Web Apps, Hold the JavaScript.

40:18 So this is a three hour course that like dives into cool ways of putting HTMX and Flask together.

40:25 And it also brings together some of the other things we've talked about on the podcast before.

40:29 Like when I was creating this course, I didn't really like the way that you would reuse HTML.

40:35 I have a lot of duplication and other crummy stuff.

40:36 So I created the ginger partials and Chameleon Partials projects to make this code better.

40:42 But anyone who uses HTMX 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:49 Course 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 We build like a really fun little app there and add a bunch of HTMX things to it.

40:58 So link in the show notes, check that out.

41:01 Auto-optional, 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:08 >> The update is, yeah, we were talking about having, so it'll go and do auto optional stuff where if you say something is like x colon int equals none as a default value, it goes no, no, no, no, no.

41:23 That doesn't make sense.

41:24 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, I can't remember who.

41:33 But said, it'd be really cool if we could use the pipe syntax that we just talked about earlier. So auto optional has been updated to create X pipe none instead of optional of X, which is nice. Yeah, I love it. I love how the podcast helps bring some of this feedback to the world.

41:48 >>Change the world.

41:49 >>That's right. We have made a dent in the universe, Brian, and it is X pipe none. Okay. Coverage, Ned Batchelder just released coverage on Monday. So coverage six, which is a major reason. Python two has been expelled from coverage, which is all good.

42:06 And 30 third-party packages are automatically ignored, which could be a big change for some people. Alright, bunch of other stuff, you can check it out if you care a lot. Django 3.2.8 is out with a couple of bug fixes about read-only fields and admin and some regression bug going on, so check that out as well. - Sweet. - Yep.

42:24 Well, I guess this might be a time for a joke. Shall we finish it with a joke?

42:28 - Yes. - As we often do. Alright.

42:30 Going back to the very very reliable geek and poke here.

42:34 We have paired Captcha as in recapture, you know, the little pop up and you get the different panels.

42:41 You got to say like, click all of the crosswalks or click all of the dogs or whatever.

42:47 All right, Brian, let's do this together like last time.

42:52 I'll do the first one, the woman developer or just computer user trying to get through this.

42:58 So is this a traffic light or just a light?

43:02 >> No idea. I guess it would guess a traffic light.

43:06 >> Nope. Does the gray pixel in the corner also belong to the street sign?

43:13 On and on it goes.

43:15 A sad statement on our digital existence.

43:20 >> There's been some where I'm stumped.

43:23 I'm like, I don't know.

43:25 >> I know.

43:26 Next next question, please Sometimes I get thrown three times in a row so embarrassing am I am I a machine I couldn't find all the mountains. Yeah, the worst is when you find all the stuff correctly then it refreshes and go find some more of them I just found them all. Why are you doing this to me?

43:47 You seem like you like to find traffic lights here have some more You looked bored. We got some more lights for you - Yeah.

43:56 - Yeah.

43:57 - All right, well, that's the joke I brought for you all.

44:00 - Well, thanks.

44:01 And I appreciate you finding them.

44:03 That's cool.

44:04 So thanks a lot, everybody.

44:06 And we'll wrap it up for today.

44:07 And thanks everybody on the stream for joining us.

44:11 We really appreciate it.

44:12 - Yeah, thanks.

44:13 Y'all, thank you especially for being here.

44:14 - Yeah, it was really fun.

44:16 Thank you.

44:18 - Thanks for listening to Python Bytes.

44:20 Follow the show on Twitter via @PythonBytes.

44:23 Python bytes as in b y t e s. Get the full show notes over at Python bytes dot fm. If you have a news item we should cover, just visit Python bytes dot fm and click Submit in the nav bar. We're always on the lookout for sharing something cool. If you want to join us for the live recording, just visit the website and click live stream to get notified of when our next episode goes live.

44:44 That's usually happening at noon Pacific on Wednesdays over at YouTube. On behalf of myself I'm Brian Okken. This is Michael Kennedy. Thank you for listening and sharing this podcast with your friends and colleagues.

Back to show page