-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Description
Issue
When running Invoke with an empty runtime config file, the following exception is hit.
$ inv --list
Traceback (most recent call last):
File "/Users/username/miniconda2/envs/env/bin/inv", line 11, in <module>
sys.exit(program.run())
File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/program.py", line 313, in run
self.create_config()
File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/program.py", line 243, in create_config
self.config = self.config_class()
File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/config.py", line 641, in __init__
self.merge()
File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/config.py", line 927, in merge
self._merge_file('user', "Per-user")
File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/config.py", line 951, in _merge_file
merge_dicts(self._config, data)
File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/config.py", line 1170, in merge_dicts
for key, value in updates.items():
AttributeError: 'NoneType' object has no attribute 'items'
Desired Result
Passing in a valid, empty .yml file should not throw an exception.
Steps to reproduce
- Create a new directory
- Create a simple
tasks.pyfile
from invoke import task, Collection, Config
@task
def hello(ctx):
print("Hello {}".format(ctx.name))
- Create an empty
~/.invoke.yamlfile - Run
invoke --list
Fix
I think it's reasonable to just return early if the dict being passed in is None.
diff --git a/invoke/config.py b/invoke/config.py
index 6d13ac08..84501133 100644
--- a/invoke/config.py
+++ b/invoke/config.py
@@ -1174,6 +1174,9 @@ def merge_dicts(base, updates):
.. versionadded:: 1.0
"""
+ if not updates:
+ return base
+
# TODO: for chrissakes just make it return instead of mutating?
for key, value in updates.items():
# Dict values whose keys also exist in 'base' -> recurse
Let me know if you need any more information or want me to throw up a commit!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels