lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
410 stars 52 forks source link

Fix the `Dataclass` protocol and make it typing-only #207

Closed lebrice closed 1 year ago

lebrice commented 1 year ago

@dataclass class Bob: a: int = 123

assert isinstance(Bob(), Dataclass) # fine assert not isinstance(Bob, Dataclass) # This shouldn't be True, but it is!


That's because it can't tell that `__dataclass_fields__` is an *instance* attribute on the class, and not a class variable!
Therefore I removed the `runtime_checkable` wrapper.

Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>