strip-hints
strip-hints copied to clipboard
A command-line script and importable function which strips type hints from Python programs.
Would it be possible to conserve the original end of line character for Windows/Unix files?
If the hints are removed, the `typing` import should no longer be needed, except for programs which rely upon `typing` and probably are unsuitable for stripping of hints.
Running `strip-hints --inplace --to-empty getnonce.py` on https://github.com/nyuszika7h/getnonce has the following result: ```diff diff --git a/getnonce.py b/getnonce.py index 14a6e98..0ae9cc8 100755 --- a/getnonce.py +++ b/getnonce.py @@ -26,7 +26,7 @@ def finish(): input()...
Running strip-hints on a dataclass makes it invalid. strip-hints should warn about this and not strip type hints from it.
When encountering `typing.Protocol` classes, strip-hints doesn't strip the class definition, resulting in invalid syntax: ```python3 class Style(Protocol): #color: str #effect: str ``` which raises `IndentationError: expected an indented block`
Repro: create a file with a single # in it, no line ends, strip-hints it. See below for the error. This happens only on Ubuntu 18.04.2 LTS for me, it...