tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.81k stars 183 forks source link

Future support for from __future__ import annotations #599

Closed wtanksleyjr closed 2 years ago

wtanksleyjr commented 2 years ago

I added YAMLWizard to some code using plumbum's cli, and after added the required __future__ line I discovered that my main function wouldn't typecheck its command line arguments anymore. Picture something like this:

from __future__ import annotations
from plumbum import cli
# import YAMLWizard # skipped for simplicity

class app(cli.Application):
    def main(self, *dirs: cli.ExistingDirectory):
          pass

I hope it's clear what's expected here. Anyhow, what will actually happen due to the annotations feature is that the annotations get processed differently, and apparently don't work the same way. So instead of typechecking the command line as expected, the program always terminates with a runtime error that "str object is not callable."

Workarounds:

  1. Just separate cli.Application and future.annotation use into separate modules. It's what I'm doing now.
  2. Don't typecheck the command line. I did that for a bit, but it's annoying.