Skip to content

Commit

Permalink
Satisfy pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
carmenbianca committed Sep 27, 2024
1 parent 61b34d8 commit 0aebc6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs=0
disable=duplicate-code,
logging-fstring-interpolation,
implicit-str-concat,
inconsistent-quotes
inconsistent-quotes,
too-many-positional-arguments
enable=useless-suppression

[REPORTS]
Expand Down
29 changes: 14 additions & 15 deletions src/reuse/global_licensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
#: Current version of REUSE.toml.
REUSE_TOML_VERSION = 1

#: Relation between Python attribute names and TOML keys.
_TOML_KEYS = {
"paths": "path",
"precedence": "precedence",
"copyright_lines": "SPDX-FileCopyrightText",
"spdx_expressions": "SPDX-License-Identifier",
}


class PrecedenceType(Enum):
"""An enum of behaviours surrounding order of precedence for entries in a
Expand Down Expand Up @@ -99,8 +107,8 @@ def __call__(
) -> None:
# This is a hack to display the TOML's key names instead of the Python
# attributes.
if hasattr(instance, "TOML_KEYS"):
attr_name = instance.TOML_KEYS[attribute.name]
if isinstance(instance, AnnotationsItem):
attr_name = _TOML_KEYS[attribute.name]
else:
attr_name = attribute.name
source = getattr(instance, "source", None)
Expand Down Expand Up @@ -319,13 +327,6 @@ class AnnotationsItem:
REUSE.toml.
"""

TOML_KEYS = {
"paths": "path",
"precedence": "precedence",
"copyright_lines": "SPDX-FileCopyrightText",
"spdx_expressions": "SPDX-License-Identifier",
}

paths: set[str] = attrs.field(
converter=_str_to_set,
validator=_validate_collection_of(set, str, optional=False),
Expand Down Expand Up @@ -395,15 +396,13 @@ def from_dict(cls, values: dict[str, Any]) -> "AnnotationsItem":
key-value pairs for an [[annotations]] table in REUSE.toml.
"""
new_dict = {}
new_dict["paths"] = values.get(cls.TOML_KEYS["paths"])
precedence = values.get(cls.TOML_KEYS["precedence"])
new_dict["paths"] = values.get(_TOML_KEYS["paths"])
precedence = values.get(_TOML_KEYS["precedence"])
if precedence is not None:
new_dict["precedence"] = precedence
new_dict["copyright_lines"] = values.get(
cls.TOML_KEYS["copyright_lines"]
)
new_dict["copyright_lines"] = values.get(_TOML_KEYS["copyright_lines"])
new_dict["spdx_expressions"] = values.get(
cls.TOML_KEYS["spdx_expressions"]
_TOML_KEYS["spdx_expressions"]
)
return cls(**new_dict) # type: ignore

Expand Down

0 comments on commit 0aebc6e

Please sign in to comment.