i'm looking at <https://github.com/pantsbuild/pant...
# development
i'm looking at https://github.com/pantsbuild/pants/issues/7074 right now / today and i think dataclasses actually might solve some of the things we've been wanting from
, specifically things like factory methods to coerce individual arguments: https://docs.python.org/3/library/dataclasses.html#dataclasses.field.
That’d be great! See https://github.com/pantsbuild/pants/pull/8180 for installing the py36 backport 🙂
and i think it will work with mypy with a hack
And allow us to ergonomically express complex types like
Union[str, List[str]]
. The
library is really nice
it really is!!
...i might have made...a lot of progress...we'll see...
💯 1
i have something that i think people will really like
writing the PR description now
Woot! Excited to review it
i tried to allow using `@dataclass`es as `datatype()`s and i think it works, we also get static mypy type checking! https://github.com/pantsbuild/pants/pull/8181
❤️ 1
💪 1
thinking of deprecating
as well, actually
If we could make the engine work without datatype(), I’d be a big proponent of that. It’s a really impressive and clever abstraction, but if we could replace it with a free abstraction from the standard library that other tools like MyPy understand and first time contributors are more familiar with, that would be great!
that's exactly i think what this PR is doing
it's not clear we need an object wrapper at all when mypy and dataclasses do exactly the type checking and efficient tuple construction we're looking for, much more efficiently
i like the idea of
in this PR because it means that we can expect python code for pants rules to work regardless of any breaking changes in
in future python versions, for example -- rule writers can make sure to instead just write against the stable (or at least, pants-controlled)
API. this allows us to swap out the backend again later (e.g. for something that generates rust struct/enum definitions for all datatypes!!!)!!!
(interested in thoughts on that)
just pushed a change to the engine readme for the above PR which i think should make everything somewhat more clear
❤️ 1