From 03414ca09a4fc67a61f2f42918f45631075b613d Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Sat, 17 Jun 2023 00:41:23 +0200 Subject: [PATCH] Revert "Verify that path is absolute" This reverts commit c61704056343216049dd7fe7e968fe075cb0edcd. --- src/reuse/_config.py | 11 ----------- tests/test_config.py | 20 ++++++-------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/reuse/_config.py b/src/reuse/_config.py index 33cbcbdc8..cdbebff58 100644 --- a/src/reuse/_config.py +++ b/src/reuse/_config.py @@ -6,7 +6,6 @@ from dataclasses import dataclass, field from gettext import gettext as _ -from pathlib import Path from typing import Any, Dict, Optional import yaml @@ -34,9 +33,6 @@ class Config: default_factory=dict ) - def __post_init__(self) -> None: - self._validate_paths_are_absolute() - @classmethod def from_dict(cls, value: Dict[str, Any]) -> "Config": """Factory method to create a Config from a dictionary.""" @@ -72,13 +68,6 @@ def from_yaml(cls, text: str) -> "Config": """ return cls.from_dict(yaml.load(text, Loader=yaml.Loader)) - def _validate_paths_are_absolute(self) -> None: - for path in self.override_annotate_options: - if not Path(path).expanduser().is_absolute(): - raise ValueError( - _("Path '{}' must be an absolute path.").format(path) - ) - def _annotate_options_from_dict(value: Dict[str, str]) -> AnnotateOptions: return AnnotateOptions( diff --git a/tests/test_config.py b/tests/test_config.py index eeea8d488..aeb57ac7c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -5,11 +5,8 @@ """Tests for some _config.""" from inspect import cleandoc -from pathlib import Path -import pytest - -from reuse._config import AnnotateOptions, Config +from reuse._config import Config # REUSE-IgnoreStart @@ -49,11 +46,11 @@ def test_config_from_dict_override(): "default_name": "Jane Doe", "overrides": [ { - "path": "/foo", + "path": "foo", "default_name": "John Doe", }, { - "path": "/bar", + "path": "bar", "default_license": "MIT", }, ], @@ -61,14 +58,9 @@ def test_config_from_dict_override(): } result = Config.from_dict(value) assert result.global_annotate_options.name == "Jane Doe" - assert result.override_annotate_options["/foo"].name == "John Doe" - assert result.override_annotate_options["/bar"].name is None - assert result.override_annotate_options["/bar"].license == "MIT" - - -def test_config_only_absolute_path(): - with pytest.raises(ValueError): - Config(override_annotate_options={Path("hello"): AnnotateOptions()}) + assert result.override_annotate_options["foo"].name == "John Doe" + assert result.override_annotate_options["bar"].name is None + assert result.override_annotate_options["bar"].license == "MIT" def test_config_from_yaml_simple():