Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
require() only checks for existence of key, not empty value #702
If the title is cryptic, I hope a simple example will explain:
from fabric.api import * def staging(): pass def deploy(): require('hosts', provided_by=[staging])
missing_keys = filter(lambda x: x not in env, keys)
This can be improved by checking the value but would require some type-checking to ensure that values of 0 and False are handled appropriately, though it's not particularly Pythonic.
Modifying the lambda would look something like this:
missing_keys = filter(lambda x: (x in env and isinstance(env[x], (types.DictType, types.ListType, types.TupleType)) and not env[x]) or x not in env, keys)
It's probably better to use a simple for-loop as that lambda is abusive.
I've opened this issue without a patch to see if this is something you think should be pursued. If so, I'd be happy to write up a patch and corresponding tests.
I ran into the issue with the
In any event, thanks for the great package.
I think this is a reasonable change -- thanks for bringing it up!
I would probably tweak your modified lambda/loop a bit:
To be honest I am still not using Python 3 at all myself -- but I am keeping an eye on changes to my OSS projects because the next iteration of them (incl Fabric) will attempt to be one of those 2.6=>3.x hybrid codebases.
In this case I couldn't remember if