Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
About Article
Analyze Data
Archive
Best Practices
Better Outputs
Blog
Code Optimization
Code Quality
Command Line
Course
Daily tips
Dashboard
Data Analysis & Manipulation
Data Engineer
Data Visualization
DataFrame
Delta Lake
DevOps
DuckDB
Environment Management
Feature Engineer
Git
Jupyter Notebook
LLM
LLM Tools
Machine Learning
Machine Learning & AI
Machine Learning Tools
Manage Data
MLOps
Natural Language Processing
Newsletter Archive
NumPy
Pandas
Polars
PySpark
Python Helpers
Python Tips
Python Utilities
Scrape Data
SQL
Testing
Time Series
Tools
Visualization
Visualization & Reporting
Workflow & Automation
Workflow Automation

Newsletter #312: Never Use yaml.load() in Python. Here’s Why.

Newsletter #312: Never Use yaml.load() in Python. Here’s Why.

Grab your coffee. Here are this week’s highlights.


📅 Today’s Picks

Never Use yaml.load() in Python. Here’s Why.

Code example: Never Use yaml.load() in Python. Here's Why.

Problem

Has your AI assistant ever suggested yaml.load() to parse a config file?

It’s an easy mistake: yaml.load() looks like a clean way to turn YAML into a Python dict, and AI tools generate it freely because it appears in plenty of legacy code.

But yaml.load() can do more than parse text. It can execute Python objects embedded in the YAML, meaning anyone who controls that file could run shell commands on your machine.

Solution

Use yaml.safe_load() instead. It only supports standard YAML types like mappings, lists, strings, numbers, booleans, and null, and rejects anything that tries to execute code.

To catch unsafe yaml.load() calls automatically, scan your codebase with Bandit.


Context7: Stop AI Agents from Generating Deprecated Syntax

Code example: Context7: Stop AI Agents from Generating Deprecated Syntax

Problem

AI coding assistants often generate code using training data that may already be outdated.

That means if you ask for Polars 1.x code, the model may still generate deprecated 0.x APIs from older training data.

Solution

Context7 solves this by pulling the latest, version-specific library docs directly into the prompt before the assistant writes any code. That way, it generates code against the API that actually exists today.

Other capabilities:

  • One command sets it up across Cursor, Claude Code, Copilot, and 30+ clients
  • Trigger with use context7 in any prompt
  • Runs as either an MCP server or a CLI + skill, so it works with or without MCP support
  • Automatically loads version-matched docs like “Polars 1.0”

📚 Latest Deep Dives

Bandit: Audit AI-Generated Python for Security Flaws

LLMs have become extremely good at generating syntactically valid Python, but security quality has barely improved.

Veracode’s Spring 2026 GenAI Code Security Report found that security pass rates have remained stuck near 55% since 2024.

That gap exists because models learn from public code full of insecure patterns and reproduce them when prompted.

At the same time, reviewers usually verify whether code works, not whether it introduces vulnerabilities.

Bandit is a static analyzer for Python that identifies insecure patterns by matching code against 60+ Common Weakness Enumeration (CWE) rules.

This article walks through 8 common anti-patterns in AI-generated Python and how to fix them with Bandit.

📖 View Full Article


☕️ Weekly Finds

beartype [Code Quality] – Near-real-time pure-Python runtime type-checker. Decorate a function and catch type violations the moment they happen, not after a stack trace.

vulture [Code Quality] – Find dead Python code. Scans your project for unused functions, classes, imports, and variables so you can safely delete them.

pyupgrade [Code Quality] – A tool (and pre-commit hook) that automatically upgrades Python syntax to newer language versions. Drop f-strings, dict literals, and modern type hints in one sweep.

Looking for a specific tool? Explore 70+ Python tools →

Stay Current with CodeCut

Actionable Python tips, curated for busy data pros. Skim in under 2 minutes, three times a week.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran