Skip to content

Commit 9cf1afa

Browse files
Merge branch 'main' into fix-markdown-readme
2 parents 3418c2f + 7636b1b commit 9cf1afa

File tree

22 files changed

+136
-54
lines changed

22 files changed

+136
-54
lines changed

.github/workflows/check_codestyle.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
os: [ ubuntu-latest, macos-latest, windows-latest ]
23-
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
24-
exclude: # see https://github.com/actions/runner-images/issues/9770#issuecomment-2085623315
25-
- python-version: "3.7"
26-
os: macos-latest
27-
include:
28-
- python-version: "3.7"
29-
os: macos-13
23+
python-version: [ "3.14" ]
3024

3125
steps:
3226
- uses: actions/checkout@v3

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Python
2020
uses: actions/setup-python@v4
2121
with:
22-
python-version: '3.11'
22+
python-version: '3.14'
2323
- name: Install dependencies
2424
run: |
2525
sudo apt-get install graphviz-dev
@@ -28,7 +28,7 @@ jobs:
2828
- name: Generate docs
2929
run: pdoc spdx_tools -o docs/
3030
- name: Upload docs as artifact
31-
uses: actions/upload-pages-artifact@v1
31+
uses: actions/upload-pages-artifact@v3
3232
with:
3333
path: docs/
3434

.github/workflows/install_and_test.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ ubuntu-latest, macos-latest, windows-latest ]
20-
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
21-
exclude: # see https://github.com/actions/runner-images/issues/9770#issuecomment-2085623315
22-
- python-version: "3.7"
23-
os: macos-latest
24-
include:
25-
- python-version: "3.7"
26-
os: macos-13
20+
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
2721

2822
steps:
2923
- uses: actions/checkout@v3

.github/workflows/integration_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v3
16-
- name: Set up Python 3.11
16+
- name: Set up Python 3.14
1717
uses: actions/setup-python@v4
1818
with:
19-
python-version: 3.11
19+
python-version: 3.14
2020
- name: Installation
2121
run: |
2222
python -m pip install --upgrade pip

.github/workflows/prepare_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Python
2020
uses: actions/setup-python@v4
2121
with:
22-
python-version: '3.7'
22+
python-version: '3.14'
2323
- name: Set up dependencies
2424
run: |
2525
python -m pip install --upgrade pip

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ The main features of v0.8 are:
2020
stable at this point, as the spec is still evolving. SPDX3-related code is contained in a separate subpackage "spdx3"
2121
and its use is optional. We do not recommend using it in production code yet.
2222

23-
## Information
23+
Note that v0.8 only supports **writing**, not **reading** SPDX 3.0 documents.
24+
See [#760](https://github.com/spdx/tools-python/issues/760) for details.
25+
26+
# Information
2427

2528
This library implements SPDX parsers, convertors, validators and handlers in Python.
2629

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@ classifiers = [
1616
"Intended Audience :: Developers",
1717
"Intended Audience :: System Administrators",
1818
"License :: OSI Approved :: Apache Software License",
19-
"Programming Language :: Python :: 3.7",
2019
"Programming Language :: Python :: 3.8",
2120
"Programming Language :: Python :: 3.9",
2221
"Programming Language :: Python :: 3.10",
2322
"Programming Language :: Python :: 3.11",
2423
]
2524
urls = { Homepage = "https://github.com/spdx/tools-python" }
26-
requires-python = ">=3.7"
25+
requires-python = ">=3.8"
2726
dependencies = ["click", "pyyaml", "xmltodict", "rdflib", "beartype", "uritools", "license_expression", "ply", "semantic_version"]
2827
dynamic = ["version"]
2928

3029
[project.optional-dependencies]
3130
test = ["pytest", "pyshacl", "tzdata"]
3231
code_style = ["isort", "black", "flake8"]
3332
graph_generation = ["pygraphviz", "networkx"]
34-
development = ["black", "flake8", "isort", "networkx", "pytest"]
33+
development = ["black", "flake8", "isort", "networkx", "pytest", "pyshacl"]
3534

3635
[project.scripts]
3736
pyspdxtools = "spdx_tools.spdx.clitools.pyspdxtools:main"

src/spdx_tools/common/typing/dataclass_with_properties.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dataclasses import dataclass
55

66
from beartype import beartype
7-
from beartype.roar import BeartypeCallHintException
7+
from beartype.roar import BeartypeCallHintParamViolation
88

99

1010
def dataclass_with_properties(cls):
@@ -30,7 +30,7 @@ def set_field(self, value: field_type):
3030
def set_field_with_error_conversion(self, value: field_type):
3131
try:
3232
set_field(self, value)
33-
except BeartypeCallHintException as err:
33+
except BeartypeCallHintParamViolation as err:
3434
error_message: str = f"SetterError {self.__class__.__name__}: {err}"
3535

3636
# As setters are created dynamically, their argument name is always "value". We replace it by the

src/spdx_tools/spdx/parser/json/json_parser.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,33 @@
33
# SPDX-License-Identifier: Apache-2.0
44
import json
55

6-
from beartype.typing import Dict
6+
from beartype.typing import Any, Dict
77

88
from spdx_tools.spdx.model import Document
99
from spdx_tools.spdx.parser.jsonlikedict.json_like_dict_parser import JsonLikeDictParser
1010

11+
# chars we don't want to see in SBOMs
12+
CONTROL_CHARS_MAP = {
13+
8: None, # ASCII/UTF-8: backspace
14+
12: None, # ASCII/UTF-8: formfeed
15+
}
16+
17+
18+
def remove_control_chars_from_value(value: Any) -> Any:
19+
if isinstance(value, str):
20+
return value.translate(CONTROL_CHARS_MAP)
21+
elif isinstance(value, list):
22+
for i in range(len(value)):
23+
value[i] = remove_control_chars_from_value(value[i])
24+
return value
25+
26+
27+
def remove_json_control_chars_hook(pairs: list) -> dict:
28+
return {k: remove_control_chars_from_value(v) for k, v in pairs}
29+
1130

1231
def parse_from_file(file_name: str, encoding: str = "utf-8") -> Document:
1332
with open(file_name, encoding=encoding) as file:
14-
input_doc_as_dict: Dict = json.load(file)
33+
input_doc_as_dict: Dict = json.load(file, object_pairs_hook=remove_json_control_chars_hook)
1534

1635
return JsonLikeDictParser().parse(input_doc_as_dict)

src/spdx_tools/spdx/parser/jsonlikedict/snippet_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def validate_pointer_and_get_type(pointer: Dict) -> RangeType:
127127

128128
@staticmethod
129129
def convert_range_from_str(
130-
_range: Tuple[Union[int, str], Union[int, str]]
130+
_range: Tuple[Union[int, str], Union[int, str]],
131131
) -> Tuple[Union[int, str], Union[int, str]]:
132132
# XML does not support integers, so we have to convert from string (if possible)
133133
if not _range:

0 commit comments

Comments
 (0)