Thursday, May 14, 2020

Python Bytes: #181 It's time to interrogate your Python code

<p>Sponsored by Datadog: <a href="http://pythonbytes.fm/datadog"><strong>pythonbytes.fm/datadog</strong></a></p> <hr /> <p><strong>Brian #1:</strong> <a href="https://pypi.org/project/interrogate/"><strong>interrogate: checks your code base for missing docstrings</strong></a></p> <ul> <li>Suggested by Herbert Beemster</li> <li>Written and Maintained by Lynn Root, <a href="https://twitter.com/roguelynn">@roguelynn</a></li> <li>Having docstrings helps you understand code.</li> <li>They can be on methods, functions, classes, and modules, and even packages, if you put a docstring in <code>__init__.py</code> files.</li> <li>I love how docstrings pop up in editors like VS Code &amp; PyCharm do with them. If you hover over a function call, a popup shows up which includes the docstring for the function.</li> <li>Other tools like Sphinx, pydoc, docutils can generate documentation with the help of docstrings.</li> <li>But good is your project at including docstrings?</li> <li><code>interrogate</code> is a command line tool that checks your code to make sure everything has docstrings. Neato.</li> <li>What’s missing? -vv will tell you which pieces are covered and not.</li> <li>Don’t want to have everything forced to include docstrings? There are options to select what needs a docstring and what doesn’t.</li> <li>Also can be incorporated into tox testing, and CI workflows.</li> </ul> <hr /> <p><strong>Michael #2:</strong> <a href="https://towardsdatascience.com/coding-ml-tools-like-you-code-ml-models-ddba3357eace"><strong>Streamlit: Turn Python Scripts into Beautiful ML Tools</strong></a></p> <ul> <li>via <a href="https://twitter.com/DanHLawReporter/status/1179431747647397890">Daniel Hoadley</a></li> <li>Many folks come to Python from “scripting” angles</li> <li>The gap between that and interactive, high perf SPA web apps is gigantic</li> <li>Streamlit let’s you build these as if they were imperative top-to-bottom code</li> <li>Really neat tricks make callbacks act like blocking methods</li> <li>Use existing data science toolkits</li> </ul> <hr /> <p><strong>Brian #3:</strong> <a href="https://hynek.me/articles/document-your-tests/"><strong>Why You Should Document Your Tests</strong></a></p> <ul> <li>Hynek Schlawack, <a href="https://twitter.com/hynek">@hyneck</a> </li> <li>All test_ methods should include a docstring telling you or someone else the what and why of the test.</li> <li>The test name should be descriptive, and the code should be clear. But still, you can get confused in the future.</li> <li>Hynek includes a great example of a simple test that is not obvious what it’s doing because the test is checking for a side effect of an action.</li> <li>“This is quite common in testing: very often, <strong>you can’t ask questions directly</strong>. Instead you verify certain properties that prove that your code is achieving its goals.”</li> <li>“If you don’t explain <em>what</em> you’re actually testing, you force the reader (possibly future you) to deduce the main intent by looking at all of its properties. This makes it tiring and time-consuming to quickly scan a file for a certain test or to understand what you’ve <em>actually</em> broken if a test starts failing.”</li> <li>Want to make sure all of your test methods have docstrings? <ul> <li><code>interrogate -vv --fail-under 100 --whitelist-regex "test_.*" tests</code> will do the trick.</li> </ul></li> <li>See also: <a href="https://jml.io/pages/test-docstrings.html">How to write docstrings for tests</a></li> </ul> <hr /> <p><strong>Michael #4:</strong> <a href="https://holoviz.org/"><strong>HoloViz project</strong></a></p> <ul> <li>HoloViz is a coordinated effort to make browser-based data visualization in Python easier to use, easier to learn, and more powerful.</li> <li>HoloViz provides: <ul> <li>High-level tools that make it easier to apply Python plotting libraries to your data.</li> <li>A comprehensive <a href="https://holoviz.org/tutorial">tutorial</a> showing how to use the available tools together to do a wide range of different tasks.</li> <li>A <a href="https://conda.io">Conda</a> metapackage "holoviz" that makes it simple to install matching versions of libraries that work well together.</li> <li>Sample datasets to work with.</li> </ul></li> <li>Comprised of a bunch of cool independent projects</li> <li><a href="https://panel.pyviz.org">Panel</a> for making apps and dashboards for your plots from any supported plotting library</li> <li><a href="https://hvplot.pyviz.org">hvPlot</a> to quickly generate interactive plots from your data</li> <li><a href="https://holoviews.org">HoloViews</a> to help you make all of your data instantly visualizable</li> <li><a href="http://geoviews.org">GeoViews</a> to extend HoloViews for geographic data</li> <li><a href="http://datashader.org">Datashader</a> for rendering even the largest datasets</li> <li><a href="https://param.pyviz.org">Param</a> to create declarative user-configurable objects</li> <li><a href="https://colorcet.pyviz.org">Colorcet</a> for perceptually uniform colormaps.</li> </ul> <hr /> <p><strong>Brian #5:</strong> <a href="https://dev.to/rsalmei/a-cool-new-progress-bar-for-python-1c0g"><strong>A cool new progress bar for python</strong></a></p> <ul> <li>RogĂ©rio Sampaio, <a href="https://twitter.com/rsalmei">@rsalmei</a></li> <li>project: <a href="https://github.com/rsalmei/alive-progress">alive-progress</a></li> <li>Way cool CLI progress bars with or without spinners</li> <li>Clean coding interface.</li> <li>Fun features and options like sequential framing, scrolling, bouncing, delays, pausing and restarting.</li> <li>Repo README notes: <ul> <li>Great animations in the README. (we love this)</li> <li>“To do” list, encourages contributions</li> <li>“Interesting facts” <ul> <li>functional style</li> <li>extensive use of closures and generators</li> <li>no dependencies</li> </ul></li> </ul></li> <li>“Changelog highlights” <ul> <li>I love this. 1-2 lines of semicolon separated features added per version. </li> </ul></li> </ul> <hr /> <p><strong>Michael #6:</strong> <a href="https://awesome-panel.org/app"><strong>Awesome Panel</strong></a></p> <ul> <li>by Marc Skov Madsen</li> <li>Awesome Panel Project is to share knowledge on how awesome Panel is and can become.</li> <li>A curated list of awesome Panel <strong>resources</strong>.</li> <li>A <strong>gallery</strong> of awesome panel applications.</li> <li>This app as a <strong>best practice multi page app</strong> with a nice layout developed in Panel.</li> <li>Kind of meta as it’s built with Panel. :)</li> <li>Browse the gallery to get a sense of what it can do</li> </ul> <hr /> <p><strong>Extras:</strong></p> <p>Michael:</p> <ul> <li>Kevin Vanderveen created a cool COVID explorer with Streamlit <ul> <li>app: <a href="https://analysis-covid-19.herokuapp.com">https://analysis-covid-19.herokuapp.com</a></li> <li>repo: <a href="https://github.com/kvanderveen/analysis_covid_19">https://github.com/kvanderveen/analysis_covid_19</a></li> </ul></li> <li><a href="https://www.codetogether.com">Code Together for editor sharing</a></li> </ul> <p>Brian: </p> <ul> <li><a href="https://us.pycon.org/2020/online/">PyCon 2020 online</a> <ul> <li>new content still being posted, through first few weeks of May.</li> <li>My talk is up. yay! <ul> <li>Multiply your Testing Effectiveness with Parameterized Testing</li> <li><a href="https://us.pycon.org/2020/schedule/presentation/172/">description</a>, <a href="https://www.youtube.com/watch?v=2R1HELARjUk">video</a>, <a href="https://github.com/okken/talks/tree/master/2020/pycon_2020">github repo</a> with slides and code</li> </ul></li> <li>Plus lots of other great talks, tutorials, charlas, sponsor workshops, online poster hall</li> </ul></li> <li>pytest resolution <ul> <li><a href="https://twitter.com/pytestdotorg/status/1257940818255462408">https://twitter.com/pytestdotorg/status/1257940818255462408</a></li> </ul></li> </ul> <hr /> <p><strong>Joke:</strong></p> <p>O’Really book covers</p> <p><img src="https://ift.tt/3dM3OiF" alt="" /></p> <p><img src="https://ift.tt/2Z4kyOb" alt="" /></p> <p><img src="https://ift.tt/3fNJ0sU" alt="" /></p> <p><img src="https://ift.tt/3dKI1YB" alt="" /></p> <p><img src="https://ift.tt/3dOYPOn" alt="" /></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...