Wednesday, September 29, 2021

Python Bytes: #252 Jupyter is now a desktop app!

<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=3SMItn5bfKs' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <strong>us:</strong></p> <ul> <li>Check out the <a href="https://training.talkpython.fm/courses/all"><strong>courses over at Talk Python</strong></a></li> <li>And <a href="https://pythontest.com/pytest-book/"><strong>Brian’s book too</strong></a>!</li> </ul> <p>Special guest: <strong>Ethan Swan</strong> </p> <p><strong>Michael #0: <a href="https://twitter.com/shacharmirkin/status/1441291234937491459">Changing themes to DIY</a></strong></p> <p><strong>Brian #1:</strong> <a href="https://www.sqlfluff.com/"><strong>SQLFluff</strong></a></p> <ul> <li>Suggested by Dave Kotchessa.</li> <li>A SQL Linter, written in Python, tested with pytest</li> <li>Configurable, and configuration can live in many places including <code>tox.ini</code> and <code>pyproject.toml</code>.</li> <li><a href="https://docs.sqlfluff.com/en/stable/">Great docs</a></li> <li><a href="https://docs.sqlfluff.com/en/stable/rules.html">Rule reference</a> with anti-pattern/best practice format</li> <li>Includes dialects for ANSI, PostgreSQL, MySQL, Teradata, BigQuery, Snoflake</li> <li>Note in docs: “<strong>SQLFluff</strong> is still in an open alpha phase - expect the tool to change significantly over the coming months, and expect potentially non-backward compatible api changes to happen at any point.”</li> </ul> <p><strong>Michael #2:</strong> <a href="https://blog.jupyter.org/jupyterlab-desktop-app-now-available-b8b661b17e9a"><strong>JupyterLab Desktop</strong></a></p> <ul> <li><a href="https://github.com/jupyterlab/jupyterlab_app">JupyterLab App</a> is the cross-platform standalone application distribution of <a href="https://github.com/jupyterlab/jupyterlab">JupyterLab</a>.</li> <li>Bundles a Python environment with several popular Python libraries ready to use in scientific computing and data science workflows.</li> <li>JupyterLab App works on Debian and Fedora based Linux, macOS and Windows operating systems.</li> </ul> <p><strong>Ethan #3:</strong> <a href="https://github.com/reclosedev/requests-cache/"><strong>Requests Cache</strong></a></p> <ul> <li>Create a requests_cache session and call HTTP methods from there <ul> <li>You can also do it without a session but that’s a bit weird, looks like it’s monkey patching requests or something…</li> </ul></li> <li>Results are cached</li> <li>Very handy for repeatedly calling endpoints <ul> <li>especially if the returned data is large, or the server has to do some compute</li> </ul></li> <li>Reminds me of @functools.lru_cache </li> <li>Can set things like how long the cache should last (when to invalidate)</li> <li>Funny easter egg in example: “# Cache 400 responses as a solemn reminder of your failures”</li> </ul> <p><strong>Brian #4:</strong> <a href="https://github.com/simonw/pypi-rename"><strong>pypi-rename</strong></a></p> <ul> <li>This is a cookiecutter template from Simon Willison</li> <li>Backstory: <ul> <li>To refresh my memory on how to publish a new package with flit I created <a href="https://pypi.org/project/pytest-skip-slow/">a new pytest plugin</a>.</li> <li>Brian Skinn noticed it somehow, and suggested a better name. Thanks Brian.</li> <li>So, how to nicely rename. I searched and found Simon’s template, which is…</li> </ul></li> <li>A cookiecutter template. So you can use cookiecutter to do some of this work for you.</li> <li>But it’s based on setuptools, and I kinda like flit lately, so I just used the instructions.</li> <li>The README.md includes instructions for the steps needed: <ul> <li>Create renamed version</li> <li>Publish under new name</li> <li>Change old one to depend on new one, but be mostly empty</li> <li>Modify readme to tell people what's going on</li> <li>Publish old name as a notice</li> </ul></li> <li>Now people looking for old one will find new one.</li> <li>People just installing old one will end up with new one also since it’s a dependency.</li> </ul> <p><strong>Michael #5:</strong> <a href="https://github.com/django/django/pull/14437"><strong>Django 4 coming with Redis Adapter</strong></a></p> <ul> <li>#33012 closed New feature (fixed) → Add a Redis cache backend. </li> <li>Adds support for Redis to be used as a caching backend with Django. </li> <li>Redis is the most popular caching backend, adding it to django.core.cache module would be a great addition for developers who previously had to rely on the use of third party packages.</li> <li>It will be simpler than that provided by <code>django-redis</code>, for instance customising the serialiser is out-of-scope for the initial pass.</li> </ul> <p><strong>Ethan #6:</strong> <a href="https://www.python.org/dev/peps/pep-0612/"><strong>PEP 612</strong></a></p> <ul> <li>It wasn’t possible to type a function that took in a function and returned a function with the same signature (which is what many decorators do) <ul> <li>This creates a ParamSpec – which is much like a TypeVar, for anyone who has used them to type generic functions/classes</li> </ul></li> <li>It’s a reminder that typing is still missing features and evolving, and it’s good to accept the edge cases for now – “gradual typing” <ul> <li>Reading Fluent Python by Ramalho has influenced my view on this – don’t lose your mind trying to type crazy stuff, just accept that it’s “gradual”</li> </ul></li> <li>Mention how typing is still evolving in Python and it’s good to keep an eye out for new features that help you (see also <a href="https://www.python.org/dev/peps/pep-0645/">PEP 645</a> – using <code>int?</code> for <code>Optional[int]</code>; and <a href="https://www.python.org/dev/peps/pep-0655/">PEP 655</a> – annotating some TypedDict keys as required and others not required)</li> </ul> <p><strong>Extras</strong></p> <p><strong>Michael</strong></p> <ul> <li><a href="https://twitter.com/AntonioAndrade/status/1440637306558316546"><strong>Earsketch</strong></a></li> <li><strong>Django Critical CVE:</strong> <a href="https://github.com/advisories/GHSA-xpfp-f569-q3p2"><strong>CVE-2021-35042</strong></a> <ul> <li><strong>Vulnerable versions:</strong> &gt;= 3.0.0, &lt; 3.1.13</li> <li><strong>Patched version:</strong> 3.1.13</li> <li>Django 3.1.x before 3.1.13 and 3.2.x before 3.2.5 allows QuerySet.order_by SQL injection if order_by is untrusted input from a client of a web application.</li> </ul></li> </ul> <p><strong>Ethan</strong></p> <ul> <li><a href="https://github.com/spotify/pedalboard"><strong>Pedalboard</strong></a> <ul> <li>I happened upon this project recently and checked back, only to see that Brett Cannon was the last committer! A doc fix, like he suggested last episode</li> </ul></li> </ul> <p>Brian</p> <ul> <li><a href="https://docs.python.org/3.11/whatsnew/3.11.html#optimizations"><strong>Zero Cost Exceptions in Python 3.11</strong></a> <ul> <li>Suggested by John Hagen</li> <li>Guido, Mark Shannon, and others at Microsoft are working on speeding up Python</li> <li><a href="https://github.com/faster-cpython/ideas">faster-cpython/ideas repo</a> includes a slide deck from Guido which includes “Zero overhead” exception handling.</li> <li><a href="https://docs.python.org/3.11/whatsnew/3.11.html#optimizations">Python 3.11 “What’s New” page, Optimizations section</a> includes:</li> <li>“Zero-cost” exceptions are implemented. The cost of <code>try</code> statements is almost eliminated when no exception is raised. (Contributed by Mark Shannon in <a href="https://bugs.python.org/issue40222">bpo-40222</a>.)</li> <li>MK: I <a href="https://gist.github.com/mikeckennedy/f516c9cf2f7a69a02a815e3799b42f95"><strong>played with this a bit</strong></a>.</li> </ul></li> </ul> <p><strong>Joke:</strong> <a href="https://geek-and-poke.com/geekandpoke/2021/1/31/qa-101"><strong>QA 101</strong></a></p>

from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...