Skip to content

Commit 966703a

Browse files
committed
rel 2024.1.5
1 parent 9b2dd3a commit 966703a

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All major and minor version changes will be documented in this file. Details of
44
patch-level version changes can be found in [commit messages](../../commits/master).
55

6+
## 2024.1.5 - 2024/04/04
7+
8+
- fix critical TypeError: can only join an iterable
9+
610
## 2024.1.4 - 2024/03/30
711

812
- fix critical https://github.com/FHPythonUtils/LicenseCheck/issues/75 where importlib.metadata.PackageMetadata.json does not exist in Python < 3.10

documentation/reference/licensecheck/packageinfo.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## _pkgMetadataGet
1818

19-
[Show source in packageinfo.py:17](../../../licensecheck/packageinfo.py#L17)
19+
[Show source in packageinfo.py:18](../../../licensecheck/packageinfo.py#L18)
2020

2121
Get a string from a key from pkgMetadata.
2222

@@ -32,7 +32,7 @@ def _pkgMetadataGet(
3232

3333
## getModuleSize
3434

35-
[Show source in packageinfo.py:192](../../../licensecheck/packageinfo.py#L192)
35+
[Show source in packageinfo.py:193](../../../licensecheck/packageinfo.py#L193)
3636

3737
Get the size of a given module as an int.
3838

@@ -61,7 +61,7 @@ def getModuleSize(path: Path, name: ucstr) -> int: ...
6161

6262
## getMyPackageLicense
6363

64-
[Show source in packageinfo.py:173](../../../licensecheck/packageinfo.py#L173)
64+
[Show source in packageinfo.py:174](../../../licensecheck/packageinfo.py#L174)
6565

6666
Get the package license from "setup.cfg", "pyproject.toml" or user input.
6767

@@ -83,7 +83,7 @@ def getMyPackageLicense() -> ucstr: ...
8383

8484
## getMyPackageMetadata
8585

86-
[Show source in packageinfo.py:144](../../../licensecheck/packageinfo.py#L144)
86+
[Show source in packageinfo.py:145](../../../licensecheck/packageinfo.py#L145)
8787

8888
Get the package classifiers and license from "setup.cfg", "pyproject.toml".
8989

@@ -101,7 +101,7 @@ def getMyPackageMetadata() -> dict[str, Any]: ...
101101

102102
## getPackageInfoLocal
103103

104-
[Show source in packageinfo.py:25](../../../licensecheck/packageinfo.py#L25)
104+
[Show source in packageinfo.py:26](../../../licensecheck/packageinfo.py#L26)
105105

106106
Get package info from local files including version, author
107107
and the license.
@@ -134,7 +134,7 @@ def getPackageInfoLocal(requirement: ucstr) -> PackageInfo: ...
134134

135135
## getPackageInfoPypi
136136

137-
[Show source in packageinfo.py:62](../../../licensecheck/packageinfo.py#L62)
137+
[Show source in packageinfo.py:63](../../../licensecheck/packageinfo.py#L63)
138138

139139
Get package info from local files including version, author
140140
and the license.
@@ -167,7 +167,7 @@ def getPackageInfoPypi(requirement: ucstr) -> PackageInfo: ...
167167

168168
## getPackages
169169

170-
[Show source in packageinfo.py:119](../../../licensecheck/packageinfo.py#L119)
170+
[Show source in packageinfo.py:120](../../../licensecheck/packageinfo.py#L120)
171171

172172
Get dependency info.
173173

@@ -196,7 +196,7 @@ def getPackages(reqs: set[ucstr]) -> set[PackageInfo]: ...
196196

197197
## licenseFromClassifierlist
198198

199-
[Show source in packageinfo.py:95](../../../licensecheck/packageinfo.py#L95)
199+
[Show source in packageinfo.py:96](../../../licensecheck/packageinfo.py#L96)
200200

201201
Get license string from a list of project classifiers.
202202

licensecheck/packageinfo.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import configparser
66
import contextlib
7+
from collections.abc import Iterable
78
from importlib import metadata
89
from pathlib import Path
910
from typing import Any
@@ -17,9 +18,9 @@
1718
def _pkgMetadataGet(pkgMetadata: metadata.PackageMetadata | dict[str, Any], key: str) -> str:
1819
"""Get a string from a key from pkgMetadata."""
1920
value = pkgMetadata.get(key, UNKNOWN)
20-
if not isinstance(value, str):
21-
value = JOINS.join(value)
22-
return value or UNKNOWN
21+
if not isinstance(value, str) and isinstance(value, Iterable):
22+
value = JOINS.join(str(x) for x in value)
23+
return str(value) or UNKNOWN
2324

2425

2526
def getPackageInfoLocal(requirement: ucstr) -> PackageInfo:

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "licensecheck"
3-
version = "2024.1.4"
3+
version = "2024.1.5"
44
license = "mit"
55
description = "Output the licenses used by dependencies and check if these are compatible with the project license"
66
authors = ["FredHappyface"]

tests/test_packageinfo.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from pathlib import Path
2+
from typing import Any
3+
4+
import pytest
25

36
from licensecheck import packageinfo, types
47

@@ -80,3 +83,22 @@ def test_getModuleSize() -> None:
8083
Path("this_package_does_not_exist"), types.ucstr("this_package_does_not_exist")
8184
)
8285
assert size == 0
86+
87+
88+
# Define test cases
89+
@pytest.mark.parametrize(
90+
"pkg_metadata, key, expected",
91+
[
92+
({"name": "Package Name", "version": "1.0"}, "name", "Package Name"),
93+
({"name": ["Package Name"], "version": "1.0"}, "name", "Package Name"),
94+
({"name": [1], "version": "1.0"}, "name", "1"),
95+
({"name": 1, "version": "1.0"}, "name", "1"),
96+
({"name": None, "version": "1.0"}, "name", "None"),
97+
({"name": ["Package Name"], "version": "1.0"}, "name", "Package Name"),
98+
({"name": ["Package", "Name"], "version": "1.0"}, "name", "Package;; Name"),
99+
({}, "name", types.UNKNOWN),
100+
({"name": "Package Name", "version": "1.0"}, "description", types.UNKNOWN),
101+
],
102+
)
103+
def test_pkgMetadataGet(pkg_metadata: dict[str, Any], key: str, expected: str):
104+
assert packageinfo._pkgMetadataGet(pkg_metadata, key) == expected

0 commit comments

Comments
 (0)