Skip to content

How do I use mando directly, i.e., without a decorator? - Failing tests included…#50

Closed
SamuelMarks wants to merge 1 commit intorubik:masterfrom
SamuelMarks:no_decorator_usage
Closed

How do I use mando directly, i.e., without a decorator? - Failing tests included…#50
SamuelMarks wants to merge 1 commit intorubik:masterfrom
SamuelMarks:no_decorator_usage

Conversation

@SamuelMarks
Copy link

[mando/tests/test_no_decorator.py] Test usage (with direct use, not as decorator); [.editorconfig] Init

@rubik
Copy link
Owner

rubik commented Sep 18, 2020

@SamuelMarks Hi Samuel, thanks for the new test. The main problem with it is that Mando does not recognize the doc format automatically, you have to specify it in the @command (or Program.command) call like this: @command(doctype='numpy'). So instead of doing self.program.command(f) you need to do self.program.command(doctype='numpy')(f). The .editorconfig file should also be removed, and to be honest I don't like the use of deque, map, etc. like that because they are not idiomatic and very difficult to read.

All that said, it appears that there is an issue with NumPy doc parsing. So I'll close this PR in favor of #51. There is no issue with using Mando without decorators, but your test caught some other bug.

@rubik rubik closed this Sep 18, 2020
@SamuelMarks
Copy link
Author

SamuelMarks commented Sep 20, 2020

@rubik I only used builtins for my code, and the only helper was a little snippet from the official Python documentation.

In the meantime I wrote my own solution for this, using the builtin ast module: https://github.com/SamuelMarks/doctrans

EDIT: Just checked the PR you opened. I don't understand, why not just edit my PR instead of taking my commit? - Unless the goal is to prevent my name from appearing in the list of committors? - In terms of auto-detecting the doctype, that's not too difficult, I can probably whip something up…

@rubik
Copy link
Owner

rubik commented Sep 21, 2020

Don't worry, your name will appear in the changelog if my PR is merged. It's such a petty reason to bring up, why would you think that when I'm always happy to receive PRs and I merge almost all of them?

I cannot edit your PR, it's in your fork. And there were too many changes to list them out so I did them directly in this repository. The builtins are not the issue, it was that the test code was unreadable and complex to reason about. Which is why initially I didn't see the issue. By rewriting it I was able to clearly understand that there was no problem with using Mando programmatically, which was the original reason this PR was opened, but that it was all working fine except possibly the NumPy docs parsing.

@SamuelMarks SamuelMarks deleted the no_decorator_usage branch September 22, 2020 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants