strip-hints icon indicating copy to clipboard operation
strip-hints copied to clipboard

Ignore dataclasses

Open d3dave opened this issue 4 years ago • 3 comments

Running strip-hints on a dataclass makes it invalid. strip-hints should warn about this and not strip type hints from it.

d3dave avatar Oct 25 '21 10:10 d3dave

any update or workaround on this?

obackhouse avatar Feb 18 '25 13:02 obackhouse

Many people seem to be using this tool. I'm curious what the use-case is when you want dataclasses but also want to strip the rest of the hints.

I'm testing a workaround where commented lines like # strip-hints: off and # strip-hints: on would toggle stripping.

abarker avatar Feb 19 '25 16:02 abarker

I just pushed out version 0.1.13. Any comment line that starts with # strip-hints: off will turn off stripping until another comment line that starts with # strip-hints: on. These examples toggle stripping for the dataclass:

@dataclass
class Point:
    # strip-hints: off
    x: int
    y: int
    # strip-hints: on

# strip-hints: off
@dataclass
class Point:
    x: int
    y: int
# strip-hints: on

abarker avatar Feb 21 '25 01:02 abarker