extras
Useful extra bits for Python - things that shold be in the standard library
What it is and what it does
extras is a small standard-library extension module originally factored out from testtools. It provides three utility functions for safer and more flexible attribute and import handling: try_import attempts to import a module and returns None on failure, try_imports tries a sequence of imports and returns the first successful one, and safe_hasattr checks for attribute existence without triggering property side effects.
The package has no runtime dependencies and installs as a pure-Python wheel with low friction. It is intended for developers who want cleaner code when dealing with optional dependencies or when they need to check for attributes in ways that avoid unintended side effects from property getters.
Use it for:
- Gracefully handle optional dependencies in a library without try-except boilerplate
- Attempt imports from multiple sources and use the first available one
- Check for attribute existence on objects with properties that have side effects
- Reduce defensive import patterns in helper modules
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides three utility functions—try_import, try_imports, and safe_hasattr—that extend Python's standard library to handle optional imports and safe attribute checking.
Yes, if you need safe optional-import handling or attribute checking without side effects. The package is stable, has no dependencies, and carries permissive licensing. However, the last release was 2016-05-18 and the codebase is aging; verify that its behavior aligns with your Python version and use case before adopting it in new projects.
Install
extras on PyPI
pip
pip install extrasuv
uv add extraspoetry
poetry add extrasInstalling extras
Before you install
Low install friction with a pure-Python wheel. Maintenance is aging: last release was 2016-05-18 and repository has not been updated since 2026-02-03, though it remains unarchived.
License in practice
Distributed under the MIT license, which is permissive and carries no restrictions on commercial or private use.
Quickstart
pip install extras
import extras
mod = extras.try_import('some_optional_module')
has_attr = extras.safe_hasattr(obj, 'attribute_name')
Verify before relying
- Whether try_import and try_imports handle exceptions beyond ImportError
- Whether safe_hasattr differs meaningfully from getattr with a default in modern Python
- Current compatibility with Python 3 versions beyond what the fact sheet specifies
Package facts
| License | UNKNOWN (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 3,740 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 599,330/month — #5,829 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: extras-1.0.0-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
lazy-importsDefers loading of module attributes and their…
permissive · top 5,000 on PyPI
mockmock provides a backport of Python's standard…
permissive · top 1,000 on PyPI
testtoolstesttools extends Python's standard unittest…
permissive · top 5,000 on PyPI
noneA library providing additional utilities and…
permissive · top 15,000 on PyPI
streamlit-extrasProvides a collection of reusable UI components…
permissive · top 15,000 on PyPI
urllib3-secure-extraDetects whether urllib3 was installed with the…
permissive · top 5,000 on PyPI
types-mockProvides type stubs for the mock library,…
permissive · top 5,000 on PyPI
emportEmport provides a single function to import…
permissive · top 15,000 on PyPI
SQLAlchemy-UtilsProvides utility functions, custom data types,…
permissive · top 1,000 on PyPI
pyflakesPyflakes checks Python source files for logical…
permissive · top 1,000 on PyPI