Python Developer Tips: Boto3, Code Reviews, and Docker
Introduction
In this episode of Python Bytes, hosts Michael Kennedy and Brian Ockett are joined by Greg Herrera to discuss the latest updates and best practices in the Python ecosystem. They cover everything from improving developer tools to managing infrastructure and code quality.
Developer Productivity and Tools
Enhancing Boto3 with Type Annotations
Michael highlights a significant pain point when working with the Boto3 API for AWS: the lack of intuitive type hints, which often leads to mysterious runtime errors.
• He suggests using the boto3-type-annotations library, which allows developers to get full autocomplete and type checking in editors like PyCharm or VS Code.
• This addition bridges the gap between dynamic AWS service calls and static type analysis.
Mastering Code Reviews
Brian discusses an insightful guide on how to make your code reviewer fall in love with you (figuratively!). Key takeaways include:
• Respect your reviewer's time: Do not just check for mistakes; pre-review your own code before submitting it.
• Clearly articulate the 'Why': Every PR description should focus on the objective and the why behind the change, not just the technical details of the diff.
• Narrow the scope: Avoid mixing refactoring, formatting, and functional changes in a single Pull Request.
"Respond graciously to critiques. Think about those as the reviewer wanting to make the code theirs as well as yours."
Infrastructure and Operations
Repository Health Tracking
Greg introduces RepoDash, a tool for gauging the health of open-source projects. It tracks vital statistics such as:
• Rate of issue resolution.
• Number of open PRs vs. closed PRs.
• Activity trends to identify if a project is actively maintained or abandoned.
Handling Production Vulnerabilities
Michael details his struggle with a recent CVE related to a buffer overflow in Python's core. His recommendation for Linux users facing delayed official package updates is to build Python from source using make altinstall to maintain side-by-side versions safely.
Docker and Testing Containers
• Docker issues on M1: A clever workaround using Docker contexts allows developers to offload Docker tasks from a local machine to a remote virtualized server, keeping the primary workstation efficient.
• Testcontainers-python: This library allows developers to spin up ephemeral database containers (like MySQL, Postgres, or MongoDB) directly within tests, ensuring a consistent environment without needing manual database setup.
Enterprise Adoption
Greg notes a relentless march toward Python adoption in corporate environments, with companies shifting away from proprietary business intelligence software and Excel-based workflows. The drive is fueled by the need for better scalability, higher quality code, and superior visibility compared to legacy tooling.