a-recknagel / stenotype

Support for shorthand type annotations.
MIT License
3 stars 2 forks source link

Add CLI for the backend #16

Closed a-recknagel closed 5 years ago

a-recknagel commented 5 years ago

If you want to know what a stenotype expression evaluates to, adding it to a source file and printing that variable's __annotation__ is a cumbersome workflow. We should have a CLI that works like this once stenotype was installed:

$ stenotype "bool or ?int"
typing.Union[bool, typing.Optional[int]]
$ stenotype "some invalid stenotype expression"
stenotype.ParseError: Failed in some way, maybe some useful info here: ... 

It would just call the backend, skip any assertion steps (which shouldn't be part of the backend anyway), and try to parse the expression into a standard type annotation using the typing module and its syntax.


a-recknagel commented 5 years ago

If you want to test the cli, checkout the branch from #18 and run poetry install again (new entrypoints need to be explicitly installed). After that, stenotype --help should work.