---
title: "more-itertools: the all_unique key in Python | VulCode"
description: "A fix in more-itertools, in Python: all_unique now uses the key function even when the function object is falsey, instead of silently ignoring it."
url: "https://vulcode.com/en/opensource/contributions/more-itertools"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

more-itertools/more-itertools

# more-itertools

A Python library with more routines for operating on iterables, beyond the itertools module.

[See the repository](https://github.com/more-itertools/more-itertools) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: Python
- **GitHub stars**: 4,106
- **Merged changes**: 1

## What we changed

all_unique now uses the given key function even when the function object itself is falsey, instead of silently ignoring it.

### What this work shows

- Callables and __bool__ in Python

- Helpers for iterables

- Regression tests with unittest

What was broken

### A falsey key was ignored

all_unique applied the key with map(key, iterable) if key else iterable. A callable whose __bool__ returns False was therefore skipped and the function compared items without the key: for ['A', 'B', 'C', 'b'] with a key calling casefold() it returned True.

How we fixed it

### A key is None check

The loop now picks iterable if key is None else map(key, iterable), like the other functions with a key parameter in more.py. A test with a CaseFold class, which is falsey and calls casefold(), expects False and fails without the fix.

[#1311](https://github.com/more-itertools/more-itertools/pull/1311)

## Merged change 1

- [#1311 fix: honour a falsey key in all_unique Merged 17 November 2026](https://github.com/more-itertools/more-itertools/pull/1311)

## What it taught us

Whether an argument was given is checked against None, not by its truth value, as the other functions with a key parameter in more.py do. The regression test fails without the fix and passes with it.

[More about this technology: Python](https://vulcode.com/en/technologies/python)

## Other projects we write code for

- [**funcy** Python · 3,507 stars A collection of practical functional tools for Python, including helpers for sequences, collections and iterators.](https://vulcode.com/en/opensource/contributions/funcy)

- [**python-benedict** Python · 1,606 stars A Python dict subclass with key path access and built-in reading and writing of many formats, such as JSON, YAML, TOML and CSV.](https://vulcode.com/en/opensource/contributions/python-benedict)

- [**pydash** Python · 1,449 stars A Python utility library modelled on Lo-Dash from JavaScript. It offers ready-made operations on lists, dicts and strings in a functional style.](https://vulcode.com/en/opensource/contributions/pydash)

- [**pydantic-extra-types** Python · 345 stars Extra types for data validation in Pydantic, the popular Python library: MAC addresses, time zones, semantic versions, ULIDs and many more.](https://vulcode.com/en/opensource/contributions/pydantic-extra-types)

- [**pytimeparse** Python · 296 stars A small Python module that turns time expressions such as 1h30m or 1:24 into a number of seconds.](https://vulcode.com/en/opensource/contributions/pytimeparse)

- [**Node.js** JavaScript · 123,955 stars The JavaScript runtime built on V8 that runs servers, command line tools and front-end build pipelines. It ships a built-in node:sqlite module for working with SQLite databases.](https://vulcode.com/en/opensource/contributions/nodejs)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
