Python Bytes is a weekly podcast hosted by Michael Kennedy and Brian Okken. The show is a short discussion on the headlines and noteworthy news in the Python, developer, and data science space.

#310 Calling All Tools for Readmes

November 15, 2022 00:53:44 45.62 MB Downloads: 0
Watch on YouTube

About the show

Sponsored by Microsoft for Startups Founders Hub.

Special guest:

Brian #1: Tips for clean code in Python

  • Bob Belderbos
  • Generally some great tips to think about to keep code maintainable:
    • Smaller units. Break things up into single responsibility. SRP: Single Responsibility Principle
    • Move magic numbers into constants or parameters.
    • Avoid global scope. (even though it’s not really global)
    • Use linters and auto-formatters.
    • Use very narrow try/except blocks.
    • Idiomatic Python. (Although I agree, this is a weird one as it’s hard for new people to follow).
    • Pay attention to data structure choice and learn to utilize standard structures and those in collections.
    • Use the standard libary.
    • Use mappings
    • Flat is better than nested.
  • But I’m gonna focus on the “smaller units” because it applies to modules as well.
    • Try to keep modules organized such that you can keep relevant and related code concepts in your head.

Michael #2: Mastodon is picking up speed

Adam #3: Correction to Sanic Worker Manager in v22.9

Brian #4: Some FastAPI news, and some great READMEs.

  • FastAPI 0.87.0 has some interesting notes
    • Upgraded Starlette, which includes TestClient based on HTTPX instead of Requests
    • Since that might break some peoples use of TestClient, someone named Kludex built bump-testclient to help automatically convert test code to the new interface. That’s so cool!
    • Use Ruff for linting
    • Add a Help Maintain FastAPI section to the docs that emphasizes that it’s super helpful to:
      • Help others with issues
      • Review PRs
      • Both of those sections have other expanded sections to describe what that means.
    • The FastAPI commitment to great documentation is amazing and worth emulating.
    • It also has a really good README.
      • Interesting sponsors section. Cool way for a popular project to get maintenance funding.
      • Testimonials. It’s like a sales landing page, which really, a README kinda is.
      • Other common good practices and cool items
        • Images
        • Some use of collapsable sections.
  • Other notable READMEs
    • pytest
      • short example right away to show how simple it can be to use.
    • textual and rich
      • great use of images and short examples
      • highlighting often missed features, such as pretty and inspect
      • Utilizing expandable/collapsable sections for longer examples
    • httpx
      • like pytest, shows a small example quickly,
      • redirects many other sections to more thorough docs.

Michael #5: Closevember

  • An annual event focused on sustainable open source development practices and maintainer well-being.
  • Let's support open source maintainers by helping them close issues and pull requests throughout November.
  • Over at closember.org
  • Contributing to a project carries a number of responsibilities, in order to make it as easy as possible for a project to receive that contribution.
  • For Maintainers: How to Get Ready (see site)
    • If you only want assistance with closing some issues and PRs, then tag your repo with closember and you’re all set.
    • One thing that we often find helpful is to declutter our physical and digital environment: tidying our desks a bit, decluttering our computers’ desktops, unsubscribing from some email lists ... that sort of thing.
    • I did this this month actually. Spent 6 hours completely rebuilding my desk to have zero wires and look tidy and clean (hint: 3m of industrial velcro and things stuck upside down) and formatted my computer to a fresh OS after two years.
  • For the Community: How to Participate (see site)
    • If you’ve never used GitHub before, your first step is going to be signing up for a free account.
    • Also, if you’re super new to git: talkpython.fm/git
    • If you’ve opened issues or PRs on projects in the past, you can start by taking a look at your own GitHub issues and your own PRs to see if any of them are outdated or have already been fixed—if so, close them!
    • After that, start browsing projects: take a look at your favorite projects and see if they’ve been tagged with closember, or browse the list of closember projects.
  • Check out the close boards (on the site)

Adam #6: Super simple “Cache with async power” using Cashews

  • Recently popped up in my GitHub Explore
    • Cashews: Async cache framework with simple API to build fast and reliable applications
  • Super simple out-of-the-box API
    • supports in memory, Redis, DiskCache (local sqlite)
    • one-line setup then implemented as a decorator
    • Human-friendly TTL values: example “3h”
  • Client-side caching - For example, if you are using Redis backend you do not need to make a network call on every cache request
  • Strategies for common cache issues
    • cache hits, early recalculation, soft TTL, resource locking, rate limiting!, circuit breaker
  • Has its own interface for middleware

Extras

Michael:

Adam:

Joke: JavaScript has been Banned from Twitter