- Podcasts
- Python Bytes
- #353 Hatching Another Episode
About this episodeTopics covered in this episode: OverflowAI Switching to Hatch Alpha release of the Ruff formatter What is wrong with TOML? Extras Joke See…
- OverflowAI
- Switching to Hatch
- Alpha release of the Ruff formatter
- What is wrong with TOML?
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#353 Hatching Another Episode
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 353, recorded September 18th, 2023. I am Brian Okken. And I am Michael Kennedy. This episode is brought to you by us. So please check out Talk Python Training and the new Python Testing with pytest course that's in progress, but already awesome. And also thank you to our supporters. And if you want to connect to any of us, you've got Python Bytes and Brian Okken and M Kennedy all on Fosstodon and the links are in the show notes. So let's kick it off with our first AI topic, Michael. Let's ask the AI what our first topic should be. Let's go to Stack Overflow and ask them what our first AI topic should be. No, seriously. So Stack Overflow has announced Overflow AI, which is not I'm sure they have, you know, they've got Stack Exchange with all sorts of different things like stuff for Linux, stuff for Mac, DevOps, you know, you name it. Yeah. So I don't think this
is not another AI overflow type thing in that sense. This is adding generative AI to Stack Overflow. All right. Okay. So the best way to kind of get a sense of what's going on here is there's a little video, a three minute video that seems like it could be about 45 seconds given how much content is in it.
But you know, spend 30 minutes with them and you'll get an example. So the most relevant portion, there's some stuff that we don't care about here, but the most relevant portion is when you go to Stack Overflow, you search for an answer. It gives you a list of results, right? Those results are based on traditional search, right? You know, keyword matches. And honestly, it does surprisingly well, when you go search there. But they're changing their search and this is maybe it's out now. I have a hard time time telling if it's out now as a preview you can sign up for, but you go to Stack Overflow and you search for something now you get like a ChatGPT like response if you want. And it'll say, here are some of the possible answers, but here's also just a, you know, like if you search Google or a Kagi, you might get a little snippet that just shows you the answer from Stack Overflow without taking it there.
It's kind of like that. It'll say, and here's a little bit of an answer. And then you can actually start a conversation about it. Like you would with ChatGPT, like that's cool, but it doesn't quite apply. How would you, you know, I don't, I'm not using Selenium for this. I'm using Pyrite. Could you give me an example of the same, the same process, but with Pyrite, you know, it'll try to give you the answer. Right. So that's all pretty cool. And they're integrating generative AI into the public platform into Stack Overflow for teams. I didn't know Stack Overflow for teams existed, but if I had a team, it would look really cool to use, but not, not in a huge corporation, not a ton of people working on stuff. So they're also planning to add at the moment VS Code integration or Stack Overflow and the Stack Overflow AI. So you can just like, you know, you've got your source control section, your file section. It's just got a Stack Overflow section where you can start talking to it and get
generative AI answers out of Stack Overflow. So I find there's a little bit of irony here, Brian. In that Stack Overflow was banning answers from ChatGPT. Now they're adding a feature that lets you have a conversation and query it using generative AI, which seems normal. However, one of the features they highlight in the video is you can say, none of this applies to me. AI helped me draft a question.
So the answers can't be generative AI, but the questions can be generative AI. Interesting. For the right source of AI, right? Origin, right? The Overflow AI, ChatGPT. So this is in private alpha, I guess, is the current form. But I went to, I went there, the way I discovered is I went to search for something on Stack Overflow. I said, do you want to try out the new Overflow AI search? I'm like, yes.
What is this? This looks very interesting. And in my profile under settings, I have the ability to have that turned on. It is turned on, but when I go to do search stuff, it doesn't seem to use it. So I think it's like fading in and out as they're making changes to it. But yeah, people can check that out. And then finally, VS Code extension looks cool. Where's our PyCharm one? Come on, bring it on, bring it on. I want this in PyCharm too. PyCharm also added its own little AI assistant, but I'm, I'm waiting for it to get better. Yeah, you can. Yeah, it's pretty cool.
But it's, it's not something I'm totally embracing yet. I just wanted to be, I'd like it when it rolls out completely. I'd like it to be able to be able to know, did this come from a person or from an AI? Or was it some mix of the two or something? I don't know. Right. Kind of like with, and I, and I kind of agree with them for not allowing AI people to just throw the, throw the question into ChatGPT and paste the answer into stack overflow. That's, that's not, that's not what people are expecting. So. Right. And if you want that, just put your question straight in ChatGPT, like leave out the stack overflow middle aspect. I'm sure the real concern was, you know, there's a lot of reputation stuff. There's a lot of like, this person is really good at answering questions and here's how much you've contributed. And if you just, you know, you could easily game that with AI results and I'm sure it is being gained with AI results just with a little more work, but you know,
such as the world. Yeah. It's the times are a changing. So they, they are, that's what ChatGPT told me anyway. How about you? What's your next one? Well, I was going to talk about switching to hatch. So, for packaging for Python packaging and also setting up virtual environments and stuff, I guess. So hatches, I'm okay. So for packaging, we had set up tools and then we had lots of stuff. We had like flit and hatchling and poetry and all sorts of things.
so, hatch, there's two parts to hatch. There's hatchling, which is the backend that helps you build and unbuild packages and stuff. And then there's, there's hatch, which is built. It has hatchling as part of it, but anyway, let's go through this. There's an article from Oliver and rich talking about switching to hatch. and great graphic, by the way, there's a graphic that says, I don't know where I'm going from here, but I promise it won't be boring. That's pretty cool. anyway, he was using poetry, looked at PDM and now he's thinking about hatch.
It's, possibly his new love. We don't know. It's a question mark. So, there's, there's a sentence here that bothers me and we can get back to it, but it says some prominent projects are using are enjoy using it or using hatch. I don't know if that's true, but let's go on. He does show some really cool things with, with hatch, which I didn't know it could do. For instance, when you say hatch new project, it creates a new PI project.toml file. One of the things it does in that is it creates these, these entry points to, environment like virtual environments. And they're separate ones for things like there's a default one. And then there's a test one that has like your PI test and plugins and stuff. Then there's linting that has like Pyright and black and rough and things in it. his question really was, why would I have like, why wouldn't I have like, just a dev virtual environment, but we're using a lot of extra tools now they might have dependencies that clash.
So if you do have dependencies that clash, maybe a separate virtual environment for each type of tool chain might be interesting. You are speaking my language now. I didn't really think about that, but there's about a 50, 50 chance. If I say update all the dependencies for Talk Python Training, which I think is about 50, there's the runtime ones. And then there's the reporting dev ones. And that includes some things like Jupyter notebooks for graphs and stuff. Yeah. There's about a 50, 50 chance that I'll get an error saying cannot find any solution to these requirements that you're asking for because something in the data science stack forces something to be less than or equal to, and something in the other stack is greater than or equal to.
So if you're not intersecting and you're like, well, yeah, it still runs fine. And I'm sure it'll be okay. But it's like, I'm constantly doing a dev environment and a dev tools environment in a runtime environment is actually pretty, pretty cool idea. So if you're not going to be able to do that, you're going to be able to do that.
You can have that. That's pretty, it's kind of neat. No need to use talks. This surprised me. Apparently, there's a matrix ability for hatch. So you can do a test matrix, test matrices within hatch. I don't know if you can do other, why would you do a docs matrix though? You know, so test matrix makes sense. I don't know if it makes sense anywhere else. But that's kind of neat. And then the last bit I thought was pretty cool was that, well, for what it has scripts, but I don't know if it's very convenient.
So like, say you have a Cove script for coverage within your test environment, you would run it by saying hatch run test colon Cove. It's kind of a mouthful still. So I'm not sure. It is. Yeah. Optional dependencies are kind of neat. You there's all most tools have optional dependencies, but the apparently hatch has a kind of a neat way to say so let's say in the example, you had to have two different optional dependencies for my SQL or Postgres, depending on what database you want to install.
database you want to install. A default could be just saying my SQL and it would pull in all of the requirements for my SQL. You just so you can there's an easy way to do sort of a transitive default set. So it's kind of cool. Anyway, nice. The thing I wanted to come back with was the comment of like everybody's using it. I don't think everybody's using it. If the in if you look at the hatch website, it does say all these different projects are using hatch. But some of them, it's obvious they're using hatchling. Like most of my projects use hatchling. That's not the same as using hatch.
Yeah, it could just be the build back. Yeah, just for building the wheels. Right? Exactly. That build back in is rock solid and I recommend it. The hatch is sort of the work with the top hatches that workflow tool is similar to poetry. So but still cool. I kind of like that. Poetry kind of makes you at least last time I tried it. It's sort of in had you take all of the tools with it. But hatch is more of a use the tools you want sort of a tool. So anyway. Yeah.
Yeah, that like more work. But yes, that's a lot of packages. And that's a it's like, are you sure you're not using like, go or something else that uses tons of dependencies? JavaScript? Yeah, yeah, yeah. I'm not saying it's a problem. It's just there's with 232. There's a chance there's a reasonable chance that a bunch, you know, a good bunch of those come from the non runtime stuff. There's a good chance that there's a clash between them. So this idea of multiple virtual environments. Yeah. Yeah. Yeah.
I'm assuming most of those are transitive. You're using some tool that's using some other tool. Yeah, exactly. Exactly. Cool. Okay, on to the next. Hold on. Comment from Mark in the audience says, Yeah, I feel like hatchling but not hatch is a fairly common pattern. When mentioned on Doc Python to me. Yeah. Awesome. Speaking of, speaking of, I just want to point out that episode 408 earlier this year, I had ofech on the creator of hatch, talk about hatch and its benefits and all those different things. So cool.
So not just telling you what's wrong, but checking for errors, but formatting your code based on convention, similar, but not identical to black. Black. So that's pretty cool. Let me read a few things that sky sent over here. Cause I think it's their experiences worthwhile. So Charlie says, first of all, the formatter is designed to be a drop in replacement for black, but with an excessive focus on performance and direct integration with rough.
So the smaller bits is maybe worth paying attention to more there. Yeah. So I almost missed this announcement because rough already had some, go ahead and fix it. If you can features. Yeah. I did have a few fix it things. Yeah, exactly. And like I said, I think that was about, there's a, a violation rather than a convention, right?
They all use single quotes or they all use double quotes. And I don't, there's no reason for like in the same function to have two kinds of strings unless, unless you're in that situation where like I'm saying it's possible. So I don't want to use a single quote. So I don't want to use a single quote.
So I don't have to escape the apostrophe. So I'll use a double quote for that one. Right. But other than those like sort of weird cases, you shouldn't mix. Right. I think that's more what the point of the Ruff formatter is addressing and black as well. Yeah. Well, rough has a few and a few differences from, from black as well.
Yes. And they, they call out as the formatters intended to emit near identical output when run over black formatted code. This is interesting. When run over extensively black formatted code projects like Django and Zulip, it was 99.9% the same. However, it says somewhere when run over non black formatted code, it might make different decisions than black has made.
Yeah. And I kind of like some of the decisions that they're making. Just. I do too. I do actually like them quite a bit. So I'm, I'm a fan of some of these things. It's not, it doesn't have as many features yet as, as black does in terms of like controlling certain things or, you know, but they're, they're working on it.
Yeah. So. The line feed versus carriage return line feed backslash end versus backslash R backslash end. That's a windows versus non windows. Yeah. Challenge. Right. And so I guess if you're on a windows, you don't want it to keep like unraveling that for you. I suppose. Yeah. Actually, I thought one of the things I thought I read was things about comments at the end of the line.
Black would often put like the comment on a completely, your, your comment might not match up with what it, what you actually commented against. Yeah. Yeah. Yeah. Rough is trying to be a little bit better about that. So. Yeah. The other area where this is supposed to be different intentionally says frequently black will suggest this at the same or the different.
Let's see. There's, there's some places where it's specifically different versus black. It talks about, I don't know. I haven't read it. I don't want to like mistake quoted here, but it's, it talks about there's a whole bunch of sections of the variations and so on. Yeah. Anyway, I'm, I'm excited to try it.
And, and I think it's cool that this is happening in this space. Indeed, Jeff out there asks, is there also a rough daemon like black has? I had no idea about the black daemon and I definitely don't know about the rough daemon. But what I use is, I just have the ID integrate, IDE integration for rough.
So it will automatically be running in the background, right? You get that for PyCharm and VS Code. I, I imagine it makes sense to have it run and just constantly checking. So I don't know, not, not sure. Right. This is still an alpha. So probably not. So, and also good to note it's, this isn't a set.
It is kind of a separate tool, but it's part of rough. So it's a, if you say like Ruff format, yes, exactly. So yeah. Ruff format. And I actually was thinking, I can't find my little example that I was running earlier, but there's a couple of, yeah. So you can do things like, so you can say like Ruff format, dash, dash, line length, dash, dash respect, .gitignore.
So it'll say if it's ignored and get, don't format it, please. Yeah. You know, things like packages that are installed in a virtual environment. Don't go messing with stuff that like, I don't care about. Right. If it's ignored in GitHub, I didn't get, it probably is only going to cause me trouble by messing with it.
Very cool. well, we're kind of going into the, like the inside baseball on this episode, but that's all right. next up, we've got a suggestion from Will McGugan. thought this might be good. A good one to discuss on the show. what's wrong with Toml? I'm like, I don't think anything's wrong with Toml.
So let's take a look. so there's an article, I forget calm. So it's hard to find, but Kamal Connor, cool name. what's wrong with Toml? And the gist of this really is Toml is, is great for smallish things. And even considering pyproject.toml is smallish, but interesting quote from, apparently from Martin Vignar, author of PyToml, said Toml is a bad file format.
It looks good at first glance and for really, really trivial things. It's probably good. But once I started using it and the configuration schema became more complex, I found the syntax ugly and hard to read. Not sure what he was doing with it, but anyway. So there, apparently there's some, some funkiness with big things.
It's, it's really, it's oppressive. apparently it's YAML with, some of the features taken away. So I'm not, it's not a standard yet, but apparently it's in the process. So like, what are they doing with it? That Toml is a problem. And, it's around strict YAML also is built for, what is it built for?
I don't think this is that great. Now compared to the, Toml version. Yeah, this is weird. You've got like these weird brackets with lots of, I don't think this is necessarily a problem. My take on it is I wouldn't use either of these for this purpose. Exactly. Like I would use Python, probably to describe stories, but anyway, I don't want to bash on him.
So that's just wanted to throw that out there. Awesome. Got any extras to throw out there? my extras are totally self-serving. but, I see the beginning of the episode. Yeah. So the last, so last, last week I announced, I think that I had a part one of the, my test course, all buttoned down and ready.
and it's a few minutes also. And one of the things I like about this is I learned some things that I didn't know. So you can, my favorite is you can adjust the speed so you can listen to me, at like 1.25 or 1.5 speed and it'll go faster. The other thing is you can add notes. You can add like notes for different video places and say, and then when you, when you click on it, so I'll even do it without explainer video.
It's still on the early bird special. So if people get to it by the 23rd, September 23rd, got a few more days to save 10%. If you're thinking about getting it might as well do that now. And it has the sister flask course. If you don't Django, but you flask. So those are our two sides of the same coin there.
And HTMX is just awesome. So check that out. If people are interested. Look, it's looking forward to that. Yeah. Thanks. And then if you happen to be coding in Rust, JetBrains just released a new IDE called Rust Rover. A funny name. I'm not really sure the origin of it, but it's based on the same foundation as PyCharm.
So if you're already using PyCharm or, you know, something like it, WebStorm, whatever, and you have the muscle memory for those hotkeys and basically the way it looks and feels, but you also want to do Rust. Rust Rover, Rust Rover, come on over. You know, let's do it. Nice. I haven't tried this out.
I don't do any Rust. So people who do Rust can check it out and let us know what they think. Nice. I use the C++ version also. The sea lion? Yeah. It's sort of a funny name for it. It is. They got good names. Also, Skylar Costco, who is the sky from submitting the Ruff formatter, says, It looks like --respect .gitignore is the default behavior in a Ruff formatter.
You should only need to set a flag, pass this flag. If you do want to format .gitignored files via dash dash, no respect. No respect for the .gitignore. Got no respect around here. Yeah. Some Rodney Dangerfield programming right there. You dissing the .gitignore. Come on now. New talk by the episode I just released like right before we jumped on here.
All right. So that is it. Oh, I guess one more piece of follow up. Since you asked Will McGugan says, are we Tomal? Most more hypothetical issues. I think there were some good points, but haven't faced them yet. Okay. Thanks, Will. I figured you were listening. Yeah. Brian, are you willing to face a joke?
Anyway, maybe it's, it's just best. No, it's not. But very, I got to try to read very small here. Hold on. So this is the five stages of debugging. Okay. Let me find a way to make this bigger. So I agree. There we go. So the five stages. Okay. Number one, denial. This stage is often characterized by phrases such as what?
Stage four, it's getting serious depression. Following the outburst, the programmer becomes aware. The hours have gone by unproductively. And there's still no solution in sight. The programmer becomes a listless. The posture often deteriorates. And you can see all the graphics are screaming and banging on the computer or staring at the sky.
The depression one is just sunk in the chair. And acceptance, the wheelchair is like the wheelie chair. It's turned around and it's gone. There's no one at the computer anymore. Yeah. The final stage is acceptance. The programmer finally accepts the situation, declares the bug a feature, and goes to play some Quake.
Yeah. So I just, yeah. There's tons of stages missing. Yes, this is funny. I know it's supposed to be a joke. But, like, get up. Go talk to somebody else. Don't do, like, leave the computer. That should be one of the first things you do is go, like, take a shower or take a nap or something like that and come back.
Yeah. That's very productive. I also think somewhere in there, there should be searching Stack Overflow. Yeah. And there should be another stage where you go to ChatGPT and see if it can help you. Yeah. Or duck, what, rubber ducking? Yeah, exactly. So I never really could get into the rubber duck completely of explaining the problem to a rubber duck or some inanimate object.
