Image

Python Bytes: #461 This episdoe has a typo

<strong>Topics covered in this episode:</strong><br> <ul> <li><strong><a href="https://discuss.python.org/t/pep-798-unpacking-in-comprehensions/99435?featured_on=pythonbytes">PEP 798: Unpacking in Comprehensions</a></strong></li> <li><strong><a href="https://github.com/pandas-dev/pandas/releases/tag/v3.0.0rc0?featured_on=pythonbytes">Pandas 3.0.0rc0</a></strong></li> <li><strong><a href="https://github.com/crate-ci/typos?featured_on=pythonbytes">typos</a></strong></li> <li><strong>A couple testing topics</strong></li> <li><strong>Extras</strong></li> <li><strong>Joke</strong></li> </ul><a href='https://www.youtube.com/watch?v=KOzOETk4Xtw' style='font-weight: bold;'data-umami-event="Livestream-Past" data-umami-event-episode="461">Watch on YouTube</a><br> <p><strong>About the show</strong></p> <p>Sponsored by us! Support our work through:</p> <ul> <li>Our <a href="https://training.talkpython.fm/?featured_on=pythonbytes"><strong>courses at Talk Python Training</strong></a></li> <li><a href="https://courses.pythontest.com/p/the-complete-pytest-course?featured_on=pythonbytes"><strong>The Complete pytest Course</strong></a></li> <li><a href="https://www.patreon.com/pythonbytes"><strong>Patreon Supporters</strong></a></li> </ul> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy">@mkennedy@fosstodon.org</a> / <a href="https://bsky.app/profile/mkennedy.codes?featured_on=pythonbytes">@mkennedy.codes</a> (bsky)</li> <li>Brian: <a href="https://fosstodon.org/@brianokken">@brianokken@fosstodon.org</a> / <a href="https://bsky.app/profile/brianokken.bsky.social?featured_on=pythonbytes">@brianokken.bsky.social</a></li> <li>Show: <a href="https://fosstodon.org/@pythonbytes">@pythonbytes@fosstodon.org</a> / <a href="https://bsky.app/profile/pythonbytes.fm">@pythonbytes.fm</a> (bsky)</li> </ul> <p>Join us on YouTube at <a href="https://pythonbytes.fm/stream/live"><strong>pythonbytes.fm/live</strong></a> to be part of the audience. Usually <strong>Monday</strong> at 10am PT. Older video versions available there too.</p> <p>Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to <a href="https://pythonbytes.fm/friends-of-the-show">our friends of the show list</a>, we'll never share it.</p> <p><strong>Michael #1: <a href="https://discuss.python.org/t/pep-798-unpacking-in-comprehensions/99435?featured_on=pythonbytes">PEP 798: Unpacking in Comprehensions</a></strong></p> <ul> <li>After careful deliberation, the Python Steering Council is pleased to accept PEP 798 – Unpacking in Comprehensions.</li> <li><p>Examples</p> <div class="codehilite"> <pre><span></span><code>[*it for it in its] # list with the concatenation of iterables in &#39;its&#39; {*it for it in its} # set with the union of iterables in &#39;its&#39; {**d for d in dicts} # dict with the combination of dicts in &#39;dicts&#39; (*it for it in its) # generator of the concatenation of iterables in &#39;its&#39; </code></pre> </div></li> <li><p>Also: <a href="https://discuss.python.org/t/pep-810-explicit-lazy-imports/104131/465?featured_on=pythonbytes">The Steering Council is happy to unanimously accept “PEP 810, Explicit lazy imports”</a></p></li> </ul> <p><strong>Brian #2: <a href="https://github.com/pandas-dev/pandas/releases/tag/v3.0.0rc0?featured_on=pythonbytes">Pandas 3.0.0rc0</a></strong></p> <ul> <li>Pandas 3.0.0 will be released soon, and we’re on Release candidate 0</li> <li>Here’s <a href="https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html?featured_on=pythonbytes">What’s new in Pands 3.0.0</a> <ul> <li>Dedicated string data type by default <ul> <li>Inferred by default for string data (instead of object dtype)</li> <li>The str dtype can only hold strings (or missing values), in contrast to object dtype. (setitem with non string fails)</li> <li>The missing value sentinel is always NaN (np.nan) and follows the same missing value semantics as the other default dtypes.</li> </ul></li> <li>Copy-on-Write <ul> <li>The result of <em>any</em> indexing operation (subsetting a DataFrame or Series in any way, i.e. including accessing a DataFrame column as a Series) or any method returning a new DataFrame or Series, always <em>behaves as if</em> it were a copy in terms of user API.</li> <li>As a consequence, if you want to modify an object (DataFrame or Series), the only way to do this is to directly modify that object itself.</li> </ul></li> <li>pd.col syntax can now be used in DataFrame.assign() and DataFrame.loc() <ul> <li>You can now do this: <code>df.assign(c = pd.col('a') + pd.col('b'))</code></li> </ul></li> <li>New Deprecation Policy</li> <li><a href="https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html#other-enhancements">Plus more</a></li> </ul></li> - </ul> <p><strong>Michael #3: <a href="https://github.com/crate-ci/typos?featured_on=pythonbytes">typos</a></strong></p> <ul> <li>You’ve heard about codespell … what about <a href="https://github.com/crate-ci/typos?featured_on=pythonbytes">typos</a>?</li> <li><a href="https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode&featured_on=pythonbytes">VSCode extension</a> and <a href="https://open-vsx.org/extension/tekumara/typos-vscode?featured_on=pythonbytes">OpenVSX extension</a>.</li> <li>From Sky Kasko:</li> </ul> <p><em>Like codespell, typos checks for known misspellings instead of only allowing words from a dictionary. But typos has some extra features I really appreciate, like finding spelling mistakes inside snake_case or camelCase words. For example, if you have the line:</em></p> <div class="codehilite"> <pre><span></span><code>*connecton_string<span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;sqlite:///my.db&quot;</span>* </code></pre> </div> <p><em>codespell won't find the misspelling, but typos will. It gave me the output:</em></p> <div class="codehilite"> <pre><span></span><code>*error:<span class="w"> </span><span class="sb">`</span>connecton<span class="sb">`</span><span class="w"> </span>should<span class="w"> </span>be<span class="w"> </span><span class="sb">`</span>connection<span class="sb">`</span>,<span class="w"> </span><span class="sb">`</span>connector<span class="sb">`</span><span class="w"> </span> ╭▸<span class="w"> </span>./main.py:1:1<span class="w"> </span>│1<span class="w"> </span>│<span class="w"> </span><span class="nv">connecton_string</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">&quot;sqlite:///my.db&quot;</span><span class="w"> </span> ╰╴━━━━━━━━━* </code></pre> </div> <p><em>But the main advantage for me is that typos <a href="https://github.com/tekumara/typos-lsp?featured_on=pythonbytes">has an LSP</a> that supports editor integrations like a <a href="https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode&featured_on=pythonbytes">VS Code extension</a>. As far as I can tell, codespell <a href="https://github.com/codespell-project/codespell/issues/1203?featured_on=pythonbytes">doesn't support editor integration</a>. (Note that the popular <a href="https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker&featured_on=pythonbytes">Code Spell Checker</a> VS Code extension is an unrelated project that uses a traditional dictionary approach.)</em></p> <p><em>For more on the differences between codespell and typos, here's a comparison table I found in the typos repo: https://github.com/crate-ci/typos/blob/master/docs/comparison.md</em></p> <p><em>By the way, though it's not mentioned in the <a href="https://github.com/crate-ci/typos#install">installation instructions</a>, typos is <a href="https://pypi.org/project/typos/?featured_on=pythonbytes">published on PyPI</a> and can be installed with uv tool install typos, for example. That said, I don't bother installing it, I just use the VS Code extension and run it as a <a href="https://github.com/crate-ci/typos/blob/master/docs/pre-commit.md?featured_on=pythonbytes">pre-commit hook</a>. (By the way, I'm using <a href="https://prek.j178.dev/?featured_on=pythonbytes">prek</a> instead of pre-commit now; thanks for the tip on episode #448!) It looks like typos also publishes a <a href="https://github.com/crate-ci/typos/blob/master/docs/github-action.md?featured_on=pythonbytes">GitHub action</a>, though I haven't used it.</em></p> <p><strong>Brian #4: A couple testing topics</strong></p> <ul> <li><a href="https://github.com/pablogsal/slowlify?featured_on=pythonbytes">slowlify</a> <ul> <li>suggested by Brian Skinn</li> <li>Simulate slow, overloaded, or resource-constrained machines to reproduce CI failures and hunt flaky tests.</li> <li>Requires Linux with cgroups v2</li> </ul></li> <li><a href="https://nedbatchelder.com/blog/202511/why_your_mock_breaks_later.html?featured_on=pythonbytes">Why your mock breaks later</a> <ul> <li>Ned Badthelder</li> <li>Ned’s taught us before to “Mock where the object is used, not where it’s defined.”</li> <li>To be more explicit, but probably more confusing to mock-newbies, “don’t mock things that get imported, mock the object in the file it got imported to.” <ul> <li>See? That’s probably worse. Anyway, read Ned’s post.</li> </ul></li> <li>If my project <code>myproduct</code> has user.py that uses the system builtin <code>open()</code> and we want to patch it: <ul> <li>DONT DO THIS: <code>@patch("builtins.open")</code> <ul> <li>This patches <code>open()</code> for the whole system</li> </ul></li> <li>DO THIS: <code>@patch("myproduct.user.open")</code> <ul> <li>This patches <code>open()</code> for just the user.py file, which is what we want</li> </ul></li> </ul></li> <li>Apparently this issue <a href="#">is common</a> and is mucking up using <code>coverage.py</code></li> </ul></li> </ul> <p><strong>Extras</strong></p> <p>Brian:</p> <ul> <li><a href="https://www.youtube.com/watch?v=mpR8ngthqiE">The Rise and Rise of FastAPI - mini documentary</a></li> <li><a href="https://courses.pythontest.com/lean-tdd/?featured_on=pythonbytes">“Building on Lean” chapter of LeanTDD is out</a> <ul> <li>The next chapter I’m working on is “Finding Waste in TDD”</li> <li>Notes to delete before end of show: <ul> <li>I’m not on track for an end of year completion of the first pass, so pushing goal to 1/31/26</li> <li>As requested by a reader, I’m releasing both the full-so-far versions and most-recent-chapter</li> </ul></li> </ul></li> </ul> <p>Michael:</p> <ul> <li><a href="https://vanishinggradients.fireside.fm/64?featured_on=pythonbytes">My Vanishing Gradient’s episode</a> is out</li> <li><a href="https://www.djangoproject.com/weblog/2025/dec/03/django-60-released/?featured_on=pythonbytes">Django 6 is out</a></li> </ul> <p><strong>Joke:</strong> <a href="https://github.com/thesephist/tabloid?featured_on=pythonbytes">tabloid</a> - A minimal programming language inspired by clickbait headlines</p>

https://pythonbytes.fm/episodes/show/461/this-episdoe-has-a-typo