reneeotten: @Korusuke this seems to work as intended, but the return-statement becomes a bit hard to decipher... not sure if that's a real issue but readability does count to a certain point. @Steap what do you think?
Steap: It is not super elegant, but having an "if/else" may not be that much better. I think it is down to personal preference here.
reneeotten: okay, let's merge this then
diff --git a/upt_macports/upt_macports.py b/upt_macports/upt_macports.py
index a8bf18f..59e1fe4 100644
--- a/upt_macports/upt_macports.py
+++ b/upt_macports/upt_macports.py
@@ -32,7 +32,7 @@ class MacPortsPackage(object):
             spdx2macports = json.loads(f.read())
 
         return ' '.join([spdx2macports.get(license.spdx_identifier, 'unknown')
-                        for license in self.upt_pkg.licenses])
+                        for license in self.upt_pkg.licenses]) or 'unknown'
 
     def _depends(self, phase):
         return self.upt_pkg.requirements.get(phase, [])

Update port
The `py-upt-macports` port is currently generating defunct packages, including #11 and printing empty licence name (https://github.com/macports/macports-ports/pull/4489).

Can you please update the `Portfile`?

@rajdeepbharati 
diff --git a/upt_macports/tests/test_macports_package.py b/upt_macports/tests/test_macports_package.py
index b876f67..2b78a14 100644
--- a/upt_macports/tests/test_macports_package.py
+++ b/upt_macports/tests/test_macports_package.py
@@ -10,7 +10,7 @@ class TestMacPortsPackageLicenses(unittest.TestCase):
 
     def test_no_licenses(self):
         self.package.upt_pkg.licenses = []
-        expected = ''
+        expected = 'unknown'
         self.assertEqual(self.package.licenses, expected)
 
     def test_one_license(self):

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov flake8
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup==1.2.2
flake8==7.2.0
iniconfig==2.1.0
Jinja2==3.1.6
MarkupSafe==3.0.2
mccabe==0.7.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
pytest-cov==6.0.0
spdx==2.5.1
spdx-lookup==0.3.3
tomli==2.2.1
upt==0.12
-e git+https://github.com/macports/upt-macports.git@e3905d65c8308cec8acbf38ec3b1ec1b18e8f523#egg=upt_macports

name: upt-macports
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - iniconfig==2.1.0
      - jinja2==3.1.6
      - markupsafe==3.0.2
      - mccabe==0.7.0
      - packaging==24.2
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - spdx==2.5.1
      - spdx-lookup==0.3.3
      - tomli==2.2.1
      - upt==0.12
prefix: /opt/conda/envs/upt-macports

upt_macports/tests/test_macports_package.py::TestMacPortsPackageLicenses::test_no_licenses
upt_macports/tests/test_macports_package.py::TestMacPortsPackageLicenses::test_bad_license upt_macports/tests/test_macports_package.py::TestMacPortsPackageLicenses::test_multiple_license upt_macports/tests/test_macports_package.py::TestMacPortsPackageLicenses::test_one_license upt_macports/tests/test_macports_package.py::TestMacPortsPackageArchiveType::test_known_archive upt_macports/tests/test_macports_package.py::TestMacPortsPackageArchiveType::test_no_archive upt_macports/tests/test_macports_package.py::TestMacPortsPackageArchiveType::test_unknown_archive
upt_macports/upt_macports.py
upt_macports/upt_macports.py