|
4 | 4 |
|
5 | 5 | 00:00:08 tired of dealing with tons of conflicts and spurious Git changes? You need Git pre-commit
|
6 | 6 |
|
7 |
| -00:00:13 hooks. Well, we're lucky to have Stephanie Molin on the show today, who has done a bunch of writing |
| 7 | +00:00:13 hooks. Well, we're lucky to have Stefanie Molin on the show today, who has done a bunch of writing |
8 | 8 |
|
9 | 9 | 00:00:18 and teaching of Git hooks. This is Talk Python to Me, episode 482, recorded October 24th, 2024.
|
10 | 10 |
|
|
28 | 28 |
|
29 | 29 | 00:01:19 brought to you by Bluehost. Do you need a website fast? Get Bluehost. Their AI builds your WordPress site
|
30 | 30 |
|
31 |
| -00:01:25 in minutes, and their built-in tools optimize your growth. Don't wait. Visit talkpython.fm |
| 31 | +00:01:25 in minutes, and their built-in tools optimize your growth. Don't wait. Visit talkpython.fm/ Bluehost |
32 | 32 |
|
33 |
| -00:01:31 slash Bluehost to get started. Hey, everyone. Before we jump into the interview with Stephanie, |
| 33 | +00:01:31 to get started. Hey, everyone. Before we jump into the interview with Stefanie, |
34 | 34 |
|
35 | 35 | 00:01:36 I want to tell you real quickly that I just released a blog for Talk Python. Now, we have had tons of RSS
|
36 | 36 |
|
|
42 | 42 |
|
43 | 43 | 00:02:01 really cool things on there. I've already got a couple of articles posted, but I have plans for
|
44 | 44 |
|
45 |
| -00:02:06 some interesting series. And anytime there's some more interesting announcements or exciting news I |
| 45 | +00:02:06 some interesting series. And anytime there's some more interesting announcements or exciting news |
46 | 46 |
|
47 |
| -00:02:11 want to share with Talk Python, it's going to be over on the Talk Python blog. So if you're interested, |
| 47 | +00:02:11 I want to share with Talk Python, it's going to be over on the Talk Python blog. So if you're interested, |
48 | 48 |
|
49 | 49 | 00:02:16 I would really, really appreciate it. If you go to talkpython.fm, click on blog, right in the
|
50 | 50 |
|
51 | 51 | 00:02:21 navigation or at the bottom and just subscribe to the RSS feed. That way we can stay in touch.
|
52 | 52 |
|
53 |
| -00:02:26 And with that, let's talk pre-commit hooks. Stephanie, welcome to Talk Python. It's awesome |
| 53 | +00:02:26 And with that, let's talk pre-commit hooks. Stefanie, welcome to Talk Python. It's awesome |
54 | 54 |
|
55 | 55 | 00:02:32 to have you. Thanks for having me. Yeah, really looking forward to talking about pre-commit hooks.
|
56 | 56 |
|
|
360 | 360 |
|
361 | 361 | 00:15:46 Sentry. Create your Sentry account now at talkpython.fm/Sentry. And if you sign up with the code
|
362 | 362 |
|
363 |
| -00:15:52 talkpython, all capital, no spaces, it's good for two free months of Sentry's business plan, which will give you up to |
| 363 | +00:15:52 TALKPYTHON, all capital, no spaces, it's good for two free months of Sentry's business plan, which will give you up to |
364 | 364 |
|
365 | 365 | 00:16:00 20 times as many monthly events as well as other features.
|
366 | 366 |
|
|
486 | 486 |
|
487 | 487 | 00:20:47 So this next one is pretty interesting that we're adding here in this example, and that's the rough pre-commit from straight from Astral, right?
|
488 | 488 |
|
489 |
| -00:20:57 So this is just github.com slash astral.sh, which is the company behind rough newbie. |
| 489 | +00:20:57 So this is just github.com/astral.sh, which is the company behind rough newbie. |
490 | 490 |
|
491 | 491 | 00:21:02 And this is the rough pre-commit.
|
492 | 492 |
|
493 | 493 | 00:21:04 But what's interesting about this is, well, one, that it has nothing to do with the pre-commit project.
|
494 | 494 |
|
495 | 495 | 00:21:09 But two, that this one also takes special arguments that you can pass to it.
|
496 | 496 |
|
497 |
| -00:21:14 Yeah, so I think the rough pre-commit one is just a smaller version so that it works faster with pre-commit. |
| 497 | +00:21:14 Yeah, so I think the ruff pre-commit one is just a smaller version so that it works faster with pre-commit. |
498 | 498 |
|
499 | 499 | 00:21:20 Because pre-commit will have to install these at some point.
|
500 | 500 |
|
|
524 | 524 |
|
525 | 525 | 00:22:06 So you can use the args here to provide stuff that you only want to happen when it's running in the context of pre-commit.
|
526 | 526 |
|
527 |
| -00:22:14 Yeah, and rough has a exit non-zero on fix, which means if it goes through and you say to fix it, it will fix it. |
| 527 | +00:22:14 Yeah, and ruff has a exit non-zero on fix, which means if it goes through and you say to fix it, it will fix it. |
528 | 528 |
|
529 | 529 | 00:22:21 But then it'll error out and say that wasn't a smooth transition or whatever, which is cool because that will then fail the commit itself.
|
530 | 530 |
|
|
592 | 592 |
|
593 | 593 | 00:23:53 and then it takes these arguments, I think this is an interesting point of discussion.
|
594 | 594 |
|
595 |
| -00:23:57 So the example you have in your article just says, what we're going to tell rough is dash, |
| 595 | +00:23:57 So the example you have in your article just says, what we're going to tell ruff is dash, |
596 | 596 |
|
597 | 597 | 00:24:01 dash, fix, dash, dash, exit non-zero fix, and show fixes, which is all good.
|
598 | 598 |
|
599 |
| -00:24:07 But rough can be pretty complex in its configuration, right? |
| 599 | +00:24:07 But ruff can be pretty complex in its configuration, right? |
600 | 600 |
|
601 | 601 | 00:24:11 You can say, disable flight gate, turn this one on.
|
602 | 602 |
|
|
608 | 608 |
|
609 | 609 | 00:24:21 So you can either do this argument thing, or if it's supported, you could also potentially have,
|
610 | 610 |
|
611 |
| -00:24:27 say, a rough.toml, right? |
| 611 | +00:24:27 say, a ruff.toml, right? |
612 | 612 |
|
613 | 613 | 00:24:28 Yeah.
|
614 | 614 |
|
|
618 | 618 |
|
619 | 619 | 00:24:38 Yeah, exactly.
|
620 | 620 |
|
621 |
| -00:24:38 So you just add a rough section in there and then you configure things. |
| 621 | +00:24:38 So you just add a ruff section in there and then you configure things. |
622 | 622 |
|
623 | 623 | 00:24:42 And this is stuff that you'd want to use both in your editor as well as in the pre-commit stage,
|
624 | 624 |
|
|
640 | 640 |
|
641 | 641 | 00:25:01 No, no, you don't.
|
642 | 642 |
|
643 |
| -00:25:02 So I suppose that's a massive bonus of having either the tool.rough settings in your pyproject or just a rough.toml, |
| 643 | +00:25:02 So I suppose that's a massive bonus of having either the tool.rough settings in your pyproject or just a ruff.toml, |
644 | 644 |
|
645 | 645 | 00:25:09 however you go about that, it doesn't really matter.
|
646 | 646 |
|
|
782 | 782 |
|
783 | 783 | 00:28:30 a certain standard.
|
784 | 784 |
|
785 |
| -00:28:30 I think one of them is called committizen. |
| 785 | +00:28:30 I think one of them is called commitizen. |
786 | 786 |
|
787 | 787 | 00:28:32 And so that runs on, my guess is on the commit message hook.
|
788 | 788 |
|
789 |
| -00:28:36 Committizen? |
| 789 | +00:28:36 Commitizen? |
790 | 790 |
|
791 | 791 | 00:28:37 Yes.
|
792 | 792 |
|
793 | 793 | 00:28:38 Okay.
|
794 | 794 |
|
795 |
| -00:28:38 What is this committizen about? |
| 795 | +00:28:38 What is this commitizen about? |
796 | 796 |
|
797 | 797 | 00:28:39 I haven't heard of this.
|
798 | 798 |
|
|
1524 | 1524 |
|
1525 | 1525 | 00:45:18 And I will be talking about Datamorph once again.
|
1526 | 1526 |
|
1527 |
| -00:45:21 And I'm hoping to run my third development sprint on Datamorph while I'm there. |
| 1527 | +00:45:21 And I'm hoping to run my third development sprint on Data Morph while I'm there. |
1528 | 1528 |
|
1529 | 1529 | 00:45:26 Oh, that's cool.
|
1530 | 1530 |
|
1531 |
| -00:45:27 Yeah, we'll talk about Datamorph in a second. |
| 1531 | +00:45:27 Yeah, we'll talk about Data Morph in a second. |
1532 | 1532 |
|
1533 | 1533 | 00:45:28 That's some interesting stuff.
|
1534 | 1534 |
|
|
1782 | 1782 |
|
1783 | 1783 | 00:51:11 example, pip to install this.
|
1784 | 1784 |
|
1785 |
| -00:51:12 And if you have, for example, pyproject.tomo and you specify how it should be built, then |
| 1785 | +00:51:12 And if you have, for example, pyproject.toml and you specify how it should be built, then |
1786 | 1786 |
|
1787 | 1787 | 00:51:16 all of that just happens as it normally would.
|
1788 | 1788 |
|
|
1856 | 1856 |
|
1857 | 1857 | 00:52:36 And that's also a quicker way to get started versus trying to, let's say, read the pipe,
|
1858 | 1858 |
|
1859 |
| -00:52:42 find the pipe project.tongle, read it in, parse out things. |
| 1859 | +00:52:42 find the pyproject.toml, read it in, parse out things. |
1860 | 1860 |
|
1861 | 1861 | 00:52:46 That's all stuff that can come later once you figure out exactly how you want your tool to
|
1862 | 1862 |
|
|
1890 | 1890 |
|
1891 | 1891 | 00:53:31 You can click, you can type, but if you want something built in, yeah, if you want something
|
1892 | 1892 |
|
1893 |
| -00:53:37 built in, argpars is pretty straightforward, right? |
| 1893 | +00:53:37 built in, argparse is pretty straightforward, right? |
1894 | 1894 |
|
1895 | 1895 | 00:53:39 Yeah.
|
1896 | 1896 |
|
1897 | 1897 | 00:53:40 And I think also, I mean, if you look at the pre-commit hooks repo provided by pre-commit org,
|
1898 | 1898 |
|
1899 |
| -00:53:45 a lot of them, or maybe all of them are just using argpars. |
| 1899 | +00:53:45 a lot of them, or maybe all of them are just using argparse. |
1900 | 1900 |
|
1901 | 1901 | 00:53:49 Because for most hooks, all you'll need to say is, I have an argument parser and it accepts
|
1902 | 1902 |
|
|
2512 | 2512 |
|
2513 | 2513 | 01:07:51 All right.
|
2514 | 2514 |
|
2515 |
| -01:07:52 Well, Stephanie, thank you so much for being here. |
| 2515 | +01:07:52 Well, Stefanie, thank you so much for being here. |
2516 | 2516 |
|
2517 | 2517 | 01:07:54 Let's wrap things up.
|
2518 | 2518 |
|
|
2594 | 2594 |
|
2595 | 2595 | 01:09:30 We should be right at the top.
|
2596 | 2596 |
|
2597 |
| -01:09:31 You can also find the iTunes feed at /itunes, the Google Play feed at /play, |
| 2597 | +01:09:31 You can also find the iTunes feed at /iTunes, the Google Play feed at /play, |
2598 | 2598 |
|
2599 | 2599 | 01:09:36 and the direct RSS feed at /rss on talkpython.fm.
|
2600 | 2600 |
|
|
2613 | 2613 | 01:09:56 Now get out there and write some Python code.
|
2614 | 2614 |
|
2615 | 2615 | 01:09:57 I'll see you next time.
|
2616 |
| - |
0 commit comments