Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when clime.now is imported in a module without any callables #25

Merged
merged 2 commits into from Jan 6, 2015

Conversation

uranusjr
Copy link
Contributor

@uranusjr uranusjr commented Jan 5, 2015

To reproduce, run import clime.now in an empty module.

This patch eats the exception and outputs nothing if there's nothing to print.

I also removed the cmd_func local variable because it is not needed anywhere.

uranusjr added 2 commits Jan 5, 2015
If clime.now is imported in a module with no functions at all, the
usage list would be empty. In this case next(iusages) will fail with
a StopIteration error.

This patch eats the exception and outputs nothing if there's nothing
to print.
@@ -632,7 +632,6 @@ def append_usage(cmd_name, without_name=False):
usages.append(Command(cmd_func, cmd_name).build_usage(without_name))

usages = []
cmd_func = None
Copy link
Owner

@moskytw moskytw Jan 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be deleted?

Copy link
Contributor Author

@uranusjr uranusjr Jan 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyFlakes thinks so.

(clime)tp-mba:clime uranusjr$ pyflakes clime/core.py
clime/core.py:635: local variable 'cmd_func' is assigned to but never used

Copy link
Owner

@moskytw moskytw Jan 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, yeah, that is right.

moskytw added a commit that referenced this pull request Jan 6, 2015
Fix error when clime.now is imported in a module without any callables
@moskytw moskytw merged commit 67ef3a7 into moskytw:dev Jan 6, 2015
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.

None yet

2 participants