Skip to content

Commit

Permalink
rel 2024.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
FredHappyface committed Apr 4, 2024
1 parent 9b2dd3a commit 966703a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All major and minor version changes will be documented in this file. Details of
patch-level version changes can be found in [commit messages](../../commits/master).

## 2024.1.5 - 2024/04/04

- fix critical TypeError: can only join an iterable

## 2024.1.4 - 2024/03/30

- fix critical https://github.com/FHPythonUtils/LicenseCheck/issues/75 where importlib.metadata.PackageMetadata.json does not exist in Python < 3.10
Expand Down
16 changes: 8 additions & 8 deletions documentation/reference/licensecheck/packageinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## _pkgMetadataGet

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

Get a string from a key from pkgMetadata.

Expand All @@ -32,7 +32,7 @@ def _pkgMetadataGet(

## getModuleSize

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

Get the size of a given module as an int.

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

## getMyPackageLicense

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

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

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

## getMyPackageMetadata

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

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

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

## getPackageInfoLocal

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

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

## getPackageInfoPypi

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

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

## getPackages

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

Get dependency info.

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

## licenseFromClassifierlist

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

Get license string from a list of project classifiers.

Expand Down
7 changes: 4 additions & 3 deletions licensecheck/packageinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import configparser
import contextlib
from collections.abc import Iterable
from importlib import metadata
from pathlib import Path
from typing import Any
Expand All @@ -17,9 +18,9 @@
def _pkgMetadataGet(pkgMetadata: metadata.PackageMetadata | dict[str, Any], key: str) -> str:
"""Get a string from a key from pkgMetadata."""
value = pkgMetadata.get(key, UNKNOWN)
if not isinstance(value, str):
value = JOINS.join(value)
return value or UNKNOWN
if not isinstance(value, str) and isinstance(value, Iterable):
value = JOINS.join(str(x) for x in value)
return str(value) or UNKNOWN


def getPackageInfoLocal(requirement: ucstr) -> PackageInfo:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "licensecheck"
version = "2024.1.4"
version = "2024.1.5"
license = "mit"
description = "Output the licenses used by dependencies and check if these are compatible with the project license"
authors = ["FredHappyface"]
Expand Down
22 changes: 22 additions & 0 deletions tests/test_packageinfo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from pathlib import Path
from typing import Any

import pytest

from licensecheck import packageinfo, types

Expand Down Expand Up @@ -80,3 +83,22 @@ def test_getModuleSize() -> None:
Path("this_package_does_not_exist"), types.ucstr("this_package_does_not_exist")
)
assert size == 0


# Define test cases
@pytest.mark.parametrize(
"pkg_metadata, key, expected",
[
({"name": "Package Name", "version": "1.0"}, "name", "Package Name"),
({"name": ["Package Name"], "version": "1.0"}, "name", "Package Name"),
({"name": [1], "version": "1.0"}, "name", "1"),
({"name": 1, "version": "1.0"}, "name", "1"),
({"name": None, "version": "1.0"}, "name", "None"),
({"name": ["Package Name"], "version": "1.0"}, "name", "Package Name"),
({"name": ["Package", "Name"], "version": "1.0"}, "name", "Package;; Name"),
({}, "name", types.UNKNOWN),
({"name": "Package Name", "version": "1.0"}, "description", types.UNKNOWN),
],
)
def test_pkgMetadataGet(pkg_metadata: dict[str, Any], key: str, expected: str):
assert packageinfo._pkgMetadataGet(pkg_metadata, key) == expected

0 comments on commit 966703a

Please sign in to comment.