Desk Clarity

A field guide to everyday digital problems.

The guidebook / 181 guides

Developer tools

Code, configuration and workflows. Source-linked checks to help you move forward.

Developer tools · GUIDE

Python Heapq Cannot Compare Dictionaries at Equal Priority: Add a Unique Tie Breaker

A heap accepts the first task but raises TypeError when another dictionary has the same priority.

2 min readSource-linked guide
Developer tools · GUIDE

Python Itertools.tee Memory Grows: Account for Consumer Lag

Two iterator branches consume one source at different speeds, retaining earlier values for the slower branch.

2 min readSource-linked guide
Developer tools · GUIDE

Python SQLite IN With a List: Generate Placeholders and Bind Each Value

Binding a Python list to one question mark does not expand it into an SQL IN list.

2 min readSource-linked guide
Developer tools · GUIDE

Python CSV Field Larger Than Field Limit: Raise a Measured Bound and Restore It

A CSV parser rejects one very long field even though the file opens normally.

2 min readSource-linked guide
Developer tools · GUIDE

Python Queue.empty Is Not a Reservation: Catch Empty at the Get Operation

A consumer checks that a queue has data and then blocks anyway. Make the retrieval decision atomically through the queue API.

2 min readSource-linked guide
Developer tools · GUIDE

Python ThreadPoolExecutor Appears to Ignore Exceptions: Read Every Future Result

A submitted task fails without a traceback in the caller. Collect outcomes explicitly rather than treating submit as success.

2 min readSource-linked guide
Developer tools · GUIDE

Python List Removal Skips Items: Filter First and Choose Whether to Preserve Identity

Adjacent matching items survive a cleanup loop because removal shifts the remaining indexes.

2 min readSource-linked guide
Developer tools · GUIDE

Python Dictionary Changed Size During Iteration: Choose a Snapshot or Rebuild

A dictionary cleanup raises RuntimeError after removing a key. Separate the traversal from structural changes.

2 min readSource-linked guide
Developer tools · GUIDE

Python Urljoin Drops a Path Segment: Check Reference Resolution and Origin

Joining a relative URL removes the last base segment or changes the hostname.

2 min readSource-linked guide
Developer tools · GUIDE

Python CSV Turns None Into Empty Text: Define a Reversible Null Contract

A CSV round trip cannot distinguish a missing value from an empty string.

2 min readSource-linked guide
Developer tools · GUIDE

Itertools Groupby Splits the Same Key: Sort or Accumulate Deliberately

Equal keys appear in several groups, or stored group iterators are empty later.

2 min readSource-linked guide
Developer tools · GUIDE

Dataclass Default Factory Is Not Callable: Pass a Constructor or Function

A dataclass field fails because default_factory was given a list value.

2 min readSource-linked guide
Developer tools · GUIDE

Python Cached Method Keeps an Instance Alive: Inspect Cache Ownership

Deleting an object does not release it after an lru_cache-decorated method was called.

2 min readSource-linked guide
Developer tools · GUIDE

Pathlib Join Drops the Base Directory: Check Absolute and Rooted Components

Joining a child path unexpectedly produces a path outside the chosen base.

2 min readSource-linked guide
Developer tools · GUIDE

Shutil Move Creates an Extra Directory Level: Inspect the Destination First

Moving a directory nests it inside an existing destination instead of renaming it.

2 min readSource-linked guide
Developer tools · GUIDE

Python Subprocess Loses Environment Settings: Decide Whether to Merge Env

Passing a small env dictionary causes a child process to lose inherited settings.

2 min readSource-linked guide
Developer tools · GUIDE

Asyncio Gather Raises but Other Tasks Continue: Own the Remaining Tasks

One gather task fails while sibling tasks keep running or appear to stop at program exit.

2 min readSource-linked guide
Developer tools · GUIDE

Asyncio Run Cannot Start Inside a Running Loop: Await at the Existing Boundary

A notebook or async callback raises an error when it calls asyncio.run.

2 min readSource-linked guide