Skip to content

Commit

Permalink
[issue-688] replace typing with beartype.typing
Browse files Browse the repository at this point in the history
this addresses warnings about possibly dropped typing support in some later python version

Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
  • Loading branch information
armintaenzertng committed Jun 12, 2023
1 parent c9423f3 commit 7857850
Show file tree
Hide file tree
Showing 183 changed files with 236 additions and 206 deletions.
2 changes: 1 addition & 1 deletion src/spdx_tools/common/typing/constructor_type_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from beartype.typing import List


class ConstructorTypeErrors(TypeError):
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/common/typing/type_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from dataclasses import fields
from typing import Any, Dict

from beartype.typing import Any, Dict

from spdx_tools.common.typing.constructor_type_errors import ConstructorTypeErrors

Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/clitools/pyspdxtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# limitations under the License.
import logging
import sys
from typing import List

import click
from beartype.typing import List

from spdx_tools.spdx.graph_generation import export_graph_from_document
from spdx_tools.spdx.model import Document
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/document_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from copy import deepcopy
from typing import Any, Dict, List, Union

from beartype.typing import Any, Dict, List, Union

from spdx_tools.spdx.model import Document, File, Package, Snippet

Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/graph_generation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Dict, List, Union
from beartype.typing import Dict, List, Union

from spdx_tools.spdx.model import File, Package, Snippet

Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/annotation_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.datetime_conversions import datetime_to_iso_string
from spdx_tools.spdx.jsonschema.annotation_properties import AnnotationProperty
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/checksum_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Type
from beartype.typing import Type

from spdx_tools.spdx.jsonschema.checksum_properties import ChecksumProperty
from spdx_tools.spdx.jsonschema.converter import TypedConverter
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/jsonschema/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from abc import ABC, abstractmethod
from typing import Any, Dict, Generic, Type, TypeVar

from beartype.typing import Any, Dict, Generic, Type, TypeVar

from spdx_tools.spdx.casing_tools import snake_case_to_camel_case
from spdx_tools.spdx.jsonschema.json_property import JsonProperty
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/creation_info_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.datetime_conversions import datetime_to_iso_string
from spdx_tools.spdx.jsonschema.converter import TypedConverter
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/document_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.document_utils import get_contained_spdx_element_ids
from spdx_tools.spdx.jsonschema.annotation_converter import AnnotationConverter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.jsonschema.checksum_converter import ChecksumConverter
from spdx_tools.spdx.jsonschema.converter import TypedConverter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.jsonschema.converter import TypedConverter
from spdx_tools.spdx.jsonschema.external_package_ref_properties import ExternalPackageRefProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.jsonschema.converter import TypedConverter
from spdx_tools.spdx.jsonschema.extracted_licensing_info_properties import ExtractedLicensingInfoProperty
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/file_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.jsonschema.annotation_converter import AnnotationConverter
from spdx_tools.spdx.jsonschema.checksum_converter import ChecksumConverter
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/optional_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Callable, Optional, TypeVar
from beartype.typing import Callable, Optional, TypeVar

T = TypeVar("T")
S = TypeVar("S")
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/package_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.datetime_conversions import datetime_to_iso_string
from spdx_tools.spdx.jsonschema.annotation_converter import AnnotationConverter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.jsonschema.converter import TypedConverter
from spdx_tools.spdx.jsonschema.json_property import JsonProperty
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/relationship_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Type
from beartype.typing import Any, Type

from spdx_tools.spdx.jsonschema.converter import TypedConverter
from spdx_tools.spdx.jsonschema.json_property import JsonProperty
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/jsonschema/snippet_converter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Dict, Tuple, Type
from beartype.typing import Any, Dict, Tuple, Type

from spdx_tools.spdx.jsonschema.annotation_converter import AnnotationConverter
from spdx_tools.spdx.jsonschema.converter import TypedConverter
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/model/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from enum import Enum, auto
from typing import Optional

from beartype.typing import Optional

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
from spdx_tools.common.typing.type_checks import check_types_and_set_values
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/model/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from datetime import datetime
from typing import List, Optional

from beartype.typing import List, Optional

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
from spdx_tools.common.typing.type_checks import check_types_and_set_values
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/model/extracted_licensing_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from typing import List, Optional, Union

from beartype.typing import List, Optional, Union

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
from spdx_tools.common.typing.type_checks import check_types_and_set_values
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/model/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from enum import Enum, auto
from typing import List, Optional, Union

from beartype.typing import List, Optional, Union
from license_expression import LicenseExpression

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/model/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from dataclasses import field
from datetime import datetime
from enum import Enum, auto
from typing import Dict, List, Optional, Union

from beartype.typing import Dict, List, Optional, Union
from license_expression import LicenseExpression

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/model/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from enum import Enum, auto
from typing import Optional, Union

from beartype.typing import Optional, Union

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
from spdx_tools.common.typing.type_checks import check_types_and_set_values
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/model/relationship_filters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import List
from beartype.typing import List

from spdx_tools.spdx.model import Document, Package, Relationship, RelationshipType

Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/model/snippet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from typing import List, Optional, Tuple, Union

from beartype.typing import List, Optional, Tuple, Union
from license_expression import LicenseExpression

from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/parser/actor_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
import re
from typing import Match, Optional, Pattern

from beartype.typing import Match, Optional, Pattern

from spdx_tools.spdx.model import Actor, ActorType
from spdx_tools.spdx.parser.error import SPDXParsingError
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/parser/error.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import List
from beartype.typing import List


class SPDXParsingError(Exception):
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/parser/json/json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
import json
from typing import Dict

from beartype.typing import Dict

from spdx_tools.spdx.model import Document
from spdx_tools.spdx.parser.jsonlikedict.json_like_dict_parser import JsonLikeDictParser
Expand Down
3 changes: 2 additions & 1 deletion src/spdx_tools/spdx/parser/jsonlikedict/annotation_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from datetime import datetime
from typing import Dict, List, Optional

from beartype.typing import Dict, List, Optional

from spdx_tools.spdx.datetime_conversions import datetime_from_str
from spdx_tools.spdx.model import Actor, Annotation, AnnotationType
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/parser/jsonlikedict/checksum_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Dict, Optional
from beartype.typing import Dict, Optional

from spdx_tools.spdx.model import Checksum, ChecksumAlgorithm
from spdx_tools.spdx.parser.jsonlikedict.dict_parsing_functions import json_str_to_enum_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from datetime import datetime
from typing import Dict, List, Optional

from beartype.typing import Dict, List, Optional

from spdx_tools.spdx.datetime_conversions import datetime_from_str
from spdx_tools.spdx.model import Actor, Checksum, CreationInfo, ExternalDocumentRef, Version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Any, Callable, Dict, List, Optional
from beartype.typing import Any, Callable, Dict, List, Optional

from spdx_tools.spdx.model import SpdxNoAssertion, SpdxNone
from spdx_tools.spdx.parser.error import SPDXParsingError
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Dict, List, Optional, Union
from beartype.typing import Dict, List, Optional, Union

from spdx_tools.spdx.model import ExtractedLicensingInfo, SpdxNoAssertion
from spdx_tools.spdx.parser.jsonlikedict.dict_parsing_functions import parse_field_or_no_assertion
Expand Down
3 changes: 1 addition & 2 deletions src/spdx_tools/spdx/parser/jsonlikedict/file_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Dict, List, Optional, Union

from beartype.typing import Dict, List, Optional, Union
from license_expression import LicenseExpression

from spdx_tools.spdx.model import Checksum, File, FileType, SpdxNoAssertion, SpdxNone
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Dict
from beartype.typing import Dict

from spdx_tools.spdx.model import Document
from spdx_tools.spdx.parser.error import SPDXParsingError
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Union

from beartype.typing import Union
from license_expression import ExpressionError, LicenseExpression, Licensing

from spdx_tools.spdx.model import SpdxNoAssertion, SpdxNone
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/parser/jsonlikedict/package_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from datetime import datetime
from typing import Dict, List, Optional, Union

from beartype.typing import Dict, List, Optional, Union
from license_expression import LicenseExpression

from spdx_tools.spdx.datetime_conversions import datetime_from_str
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import Dict, List, Optional
from beartype.typing import Dict, List, Optional

from spdx_tools.common.typing.constructor_type_errors import ConstructorTypeErrors
from spdx_tools.spdx.model import Relationship, RelationshipType
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/parser/jsonlikedict/snippet_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-License-Identifier: Apache-2.0
from enum import Enum, auto
from typing import Dict, List, Optional, Tuple, Union

from beartype.typing import Dict, List, Optional, Tuple, Union
from license_expression import LicenseExpression

from spdx_tools.spdx.model import Snippet, SpdxNoAssertion, SpdxNone
Expand Down
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/parser/logger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from typing import List
from beartype.typing import List


class Logger:
Expand Down
Loading

0 comments on commit 7857850

Please sign in to comment.