skillfed

strip-hints

Function and command-line program to strip Python type hints.

strip-hints v0.1.13 2.3M downloads/30d#3,179 on PyPI49
License unclear The MIT License (MIT) Copyright (c) 2017 Allen Barker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) AGING released

What it is and what it does

strip-hints is a command-line tool and Python library that removes type annotations from Python source files while attempting to preserve the syntactic structure and line/column correspondence of the original code. It was originally designed to allow Python 2 code to be developed with type hints on Python 3 but executed on Python 2; though Python 2 is no longer maintained, the tool remains useful for stripping hints from any codebase that needs to run on interpreters without type-hint support.

The package provides both a console command and importable functions for programmatic use. It includes a general-purpose TokenList class that operates on Python tokens using a string-like interface, which can be useful for other token-level code transformations. The tool handles edge cases like line breaks within type hints in annotated assignments and return type specifications, with configurable options to control how strictly line numbers are preserved.

Use it for:

  • Maintain a single codebase with type hints that must also run on older Python versions without type-hint support
  • Automatically strip hints from imported modules in the same directory to enable runtime compatibility
  • Preprocess Python code before execution on interpreters that do not support type annotations
  • Build custom code transformation tools using the TokenList class for token-level operations
  • Test or verify that code remains syntactically valid after type-hint removal

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Strips type hints from Python source code while preserving line and column numbers, leaving syntactically valid code that can run on interpreters without type-hint support.

Yes, if you need to strip type hints from Python code. The package is stable, has no known vulnerabilities, and carries a permissive MIT license. Install friction is minimal. The aging maintenance status (539 days since last release) is a minor concern but not a blocker, as the tool's scope is narrow and the repository remains active. Suitable for build pipelines, compatibility layers, or one-off code transformations.

Install

strip-hints on PyPI

pip

pip install strip-hints

uv

uv add strip-hints

poetry

poetry add strip-hints

Installing strip-hints

Before you install

Low friction: pure Python wheel with only wheel as a runtime dependency. Maintenance is aging—last release was 539 days ago, though the repository remains active with a recent commit on 2025-02-21.

License in practice

MIT license grants broad permission to use, modify, and distribute. No notable restrictions for most use cases.

Quickstart

pip install strip-hints

strip-hints your_file_with_hints.py

Or programmatically:
from strip_hints import strip_file_to_string
code_string = strip_file_to_string(filename)

Verify before relying

  • Whether the package still works reliably with modern Python 3 versions (classifiers list 3.3–3.5 but latest release is recent)
  • Whether the TokenList class and token-level API are documented or stable for external use

Package facts

License The MIT License (MIT) Copyright (c) 2017 Allen Barker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (unclear)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — wheel
Maintenance aging — 539 days since the last release
Last repo commit
First released
Downloads 2,267,977/month — #3,179 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: strip_hints-0.1.13-py3-none-any.whl

Keywords: annotations, hints, strip, type, typing

Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Utilities

Tags

remove type hints from pythonstrip annotations from codepython type hint removalconvert typed code to untypedpython 2 compatibility tooltype annotation stripperpython code transformation
code-transformationpython-compatibility

More Utilities packages