From 6e77e218214d3be85de4f42b5f2ac7a056b9a92c Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Thu, 1 Dec 2022 00:15:45 +0000 Subject: [PATCH 1/4] Do not assign None to codebase attributes #48 Signed-off-by: Jono Yang --- src/commoncode/resource.py | 2 ++ tests/test_resource.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/commoncode/resource.py b/src/commoncode/resource.py index 1da2dc9..4280b84 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 907436d..4e84523 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') From 9009d6c85d16851d3740eb454826cb7f463359b1 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 6 Dec 2022 01:23:17 +0000 Subject: [PATCH 2/4] Set version in setup.cfg Signed-off-by: Jono Yang --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index faf5636..44df27e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,6 +7,7 @@ license_files = commoncode.ABOUT README.rst name = commoncode +version = 31.0.0 author = nexB. Inc. and others author_email = info@aboutcode.org license = Apache-2.0 From 59c9c17f5724da47d14651c2f26e7447c5a7db9e Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Fri, 3 Feb 2023 17:30:18 -0800 Subject: [PATCH 3/4] Update fallback_version in pyproject.toml Signed-off-by: Jono Yang --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cde7907..17a3053 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 = [ From 3ea85487ff4dea2ba46e765df3c4e684734ab204 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Thu, 23 Feb 2023 15:15:46 -0800 Subject: [PATCH 4/4] Do not set version in setup.cfg #48 Signed-off-by: Jono Yang --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 44df27e..faf5636 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,6 @@ license_files = commoncode.ABOUT README.rst name = commoncode -version = 31.0.0 author = nexB. Inc. and others author_email = info@aboutcode.org license = Apache-2.0