Skip to main content

typing-clean

PyPI GitHub Release

Syntax sugar: import contents of built-in typing module — with protected and shortened names.
(_A for Any, _C for Callable, etc.)

TL;DR

You like type-hinted python, but you hate how much EVERY module's namespace is cluttered with typing objects? Then:

  • Instead of importing from typing or typing_extensions, import from this typing_clean;
  • Use the same objects, just their names prefixed with underscores (Iterable -> _Iterable);
  • They will stay inside your module, never auto-propagating up the import chain;
  • Ask the maintainers of the lib you use to adopt typing-clean, too.

Version

  • First two numbers: oldest Python version supported;
  • Last number: minor update within it.

The installed python and typing-extensions determine which version of typing-clean to install.

How

This module is deliberately the most barebones wrapper: it implements NOTHING. It merely imports from typing and typing_extensions with prefixed names. Any IDE should be 100% compatible with it.

What and why

By its very purpose, the entire contents of the built-in typing module is what you'd call "implementation details": whenever any of its objects get imported in a module, they should stay hidden inside the module - never to be suggested by an IDE's autocomplete when the module itself gets imported.

But, as you are well aware, this is not what happens. Instead, if you want to code typed python, you're presented a dilemma of how your own module will get polluted by typing - with either or both of:

  • typing's own objects spilled all over your module, while being irrelevant for an outer scope where your module is imported.
    • To add insult to injury, all the "standard" (i.e., non-underscored) names are by default imported into outer scope with wildcard import (from your_module import *), so your module pollutes them upstream... unless you manually add EVERYTHING your module defines by itself to its __all__.
  • importing only typing itself, but adding long prefixes of typing.SpecificType everywhere in your code.

Both clutter the code and IDE autocomplete - either in your own module or from outside.

Ideally, your module should import any typing-related objects with a private (dunder) or at least protected (_) name. But now you just move boilerplate code to the imports section, making it tedious to import each type-hinting class in each of your submodules with as:

from typing import Mapping as _Mapping, TypeVar as _TypeVar, ...

You could define your own service submodule which simply imports from typing with the right names, but then you won't be able to wildcard-import those names from it, unless you list every single name inside __all__... which is exactly what this package does:

  • The classes from typing are imported with underscore prefix;
  • many of the most used ones also have aliases where they are further shortened to just one letter (full names still available);
  • missing/updated classes are imported from typing_extensions - you get the most full set of typing classes in one place;
  • this module defines its __all__, so:
    • in your module, you can do from typing_clean import *,
    • but the imported objects come underscored, so for an outer module (where yours got imported from), they don't get wildcard-imported.

Short names

Here Built-in
_A Any
_C Callable
_G Generator
_I Iterable
_M Mapping
_NT NamedTuple
_O Optional
_U Union
_IV ItemsView
_KV KeysView
_VV ValuesView

TypeVars

The only thing the module defines by itself is a set of TypeVars:

  • both in typing and typing_extensions the defined ones aren't exported, so even though at runtime their import works just fine, some IDEs complain that they can't find them;
  • the built-in set was too short for me, so I defined extra 3 numbered versions for each.
What Built-in equivalent +Second +Third +Fourth
Just any arbitrary type _T _T2 _T3 _T4
Key type for dicts _KT _KT2 _KT3 _KT4
Value type for dicts _VT _VT2 _VT3 _VT4
Type covariant:
TypeVar(..., covariant=True)
_T_co _T2_co _T3_co _T4_co
Ditto contravariant:
TypeVar(..., contravariant=True)
_T_contra _T2_contra _T3_contra _T4_contra
Parameter specifier _P _P2 _P3 _P4

Metadata

Release files for typing-clean 3.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typing-clean 3.6.0
File Size Uploaded Provenance
typing_clean-3.6.0.tar.gz 16.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for typing-clean 3.6.0
File Interpreter ABI Platform
typing_clean-3.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.2 kB

Release files / typing_clean-3.6.0.tar.gz

Download URL typing_clean-3.6.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
397dffe0359a1bfa8b932bf8c74047f64609fc55b26b08d8e18b5866d7fbd09f
BLAKE2b-256 checksum
How to use checksums
baf76280c22fd17e65c41736864a7083ff3fc94b984e5de5da81649a7a81c069
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / typing_clean-3.6.0-py3-none-any.whl

Download URL typing_clean-3.6.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13e9daaf248d4a015bd338a75c189aea1830984d1e9b68c048002718ecdd537b
BLAKE2b-256 checksum
How to use checksums
90b2467c17693dfe04c96015a2234ee722179b619db36884ba9f640fa75573de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for typing-clean 3.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for typing_clean-3.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page