diff --git a/pyproject.toml b/pyproject.toml index cde79074..17a30535 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] # this is used populated when creating a git archive # and when there is .git dir and/or there is no git installed -fallback_version = "9999.$Format:%h-%cs$" +fallback_version = "9999.dev99" [tool.pytest.ini_options] norecursedirs = [ diff --git a/src/commoncode/resource.py b/src/commoncode/resource.py index 1da2dc95..4280b841 100644 --- a/src/commoncode/resource.py +++ b/src/commoncode/resource.py @@ -1840,6 +1840,8 @@ def _populate(self, scan_data): ########################################################## for attr_name in self.codebase_attributes: value = scan_data.get(attr_name) + if value == None: + continue setattr(self.attributes, attr_name, value) ########################################################## diff --git a/tests/test_resource.py b/tests/test_resource.py index 907436d7..4e84523b 100644 --- a/tests/test_resource.py +++ b/tests/test_resource.py @@ -12,6 +12,8 @@ from os.path import exists from os.path import join +import attr + from commoncode.fileutils import parent_directory from commoncode.resource import Codebase from commoncode.resource import Resource @@ -661,6 +663,17 @@ def test_VirtualCodebase_with_paths_works(self): ) check_against_expected_json_file(results, expected_file, regen=False) + def test_VirtualCodebase_codebase_attributes_assignment(self): + test_codebase = self.get_test_loc('resource/with_path/virtual-codebase.json') + vc = VirtualCodebase( + location=test_codebase, + codebase_attributes=dict( + packages=attr.ib(default=attr.Factory(list)) + ), + ) + self.assertNotEqual(vc.attributes.packages, None) + self.assertEqual(vc.attributes.packages, []) + class TestCodebaseCache(FileBasedTesting): test_data_dir = join(dirname(__file__), 'data')