Add mypy support to hologram. This also smooths out some of the rough edges with interaction between hologram and mypy.
Breaking Change: Because NewTypes can't be defined dynamically and mypy explicitly enforces that it's called with a string literal, users will have to pass a NewType(name, str) in to a new function (register_pattern). I don't think this is "better", but I don't really think it's worse. Maybe patterns should be metadata like restrict is instead of a standalone field encoder? It's hard to say.
I have a dbt branch that fixes the call sites, once we release 0.0.2 I can point it there
I added #type: ignore to a few places that mypy struggled with.
dataclasses.Field is a weird object and mypy gets confused. I think this is a mypy bug of some kind, but you probably aren't supposed to be messing with the default_factory attribute.
It doesn't know that you can declare a new enum type using Enum(x, x) and to be fair I didn't either. If nobody's using StrLiteral with the advent of restricted fields it can also just go away.
The default implementation of FieldEncoder makes some assumptions about types, which mypy complains about. If it doesn't work for a type, subclasses will just have to override it.
added third-party stubs for jsonschema, so this includes a mypy.ini.
mypy passes now and runs it in circle
Add mypy support to hologram. This also smooths out some of the rough edges with interaction between hologram and mypy.
Breaking Change: Because
NewType
s can't be defined dynamically and mypy explicitly enforces that it's called with a string literal, users will have to pass a NewType(name, str) in to a new function (register_pattern
). I don't think this is "better", but I don't really think it's worse. Maybe patterns should be metadata like restrict is instead of a standalone field encoder? It's hard to say.I added
#type: ignore
to a few places that mypy struggled with.dataclasses.Field
is a weird object and mypy gets confused. I think this is a mypy bug of some kind, but you probably aren't supposed to be messing with thedefault_factory
attribute.Enum(x, x)
and to be fair I didn't either. If nobody's using StrLiteral with the advent of restricted fields it can also just go away.FieldEncoder
makes some assumptions about types, which mypy complains about. If it doesn't work for a type, subclasses will just have to override it.added third-party stubs for jsonschema, so this includes a mypy.ini. mypy passes now and runs it in circle