Commit 4c29f211 by Randy Döring Committed by GitHub

chore: remove unused duplicated default values for config settings (#7355)

parent a5c38466
...@@ -16,7 +16,6 @@ from poetry.config.config import boolean_normalizer ...@@ -16,7 +16,6 @@ from poetry.config.config import boolean_normalizer
from poetry.config.config import boolean_validator from poetry.config.config import boolean_validator
from poetry.config.config import int_normalizer from poetry.config.config import int_normalizer
from poetry.console.commands.command import Command from poetry.console.commands.command import Command
from poetry.locations import DEFAULT_CACHE_DIR
if TYPE_CHECKING: if TYPE_CHECKING:
...@@ -52,74 +51,31 @@ To remove a repository (repo is a short alias for repositories): ...@@ -52,74 +51,31 @@ To remove a repository (repo is a short alias for repositories):
LIST_PROHIBITED_SETTINGS = {"http-basic", "pypi-token"} LIST_PROHIBITED_SETTINGS = {"http-basic", "pypi-token"}
@property @property
def unique_config_values(self) -> dict[str, tuple[Any, Any, Any]]: def unique_config_values(self) -> dict[str, tuple[Any, Any]]:
unique_config_values = { unique_config_values = {
"cache-dir": ( "cache-dir": (str, lambda val: str(Path(val))),
str, "virtualenvs.create": (boolean_validator, boolean_normalizer),
lambda val: str(Path(val)), "virtualenvs.in-project": (boolean_validator, boolean_normalizer),
str(DEFAULT_CACHE_DIR / "virtualenvs"), "virtualenvs.options.always-copy": (boolean_validator, boolean_normalizer),
),
"virtualenvs.create": (boolean_validator, boolean_normalizer, True),
"virtualenvs.in-project": (boolean_validator, boolean_normalizer, False),
"virtualenvs.options.always-copy": (
boolean_validator,
boolean_normalizer,
False,
),
"virtualenvs.options.system-site-packages": ( "virtualenvs.options.system-site-packages": (
boolean_validator, boolean_validator,
boolean_normalizer, boolean_normalizer,
False,
),
"virtualenvs.options.no-pip": (
boolean_validator,
boolean_normalizer,
False,
), ),
"virtualenvs.options.no-pip": (boolean_validator, boolean_normalizer),
"virtualenvs.options.no-setuptools": ( "virtualenvs.options.no-setuptools": (
boolean_validator, boolean_validator,
boolean_normalizer, boolean_normalizer,
False,
),
"virtualenvs.path": (
str,
lambda val: str(Path(val)),
str(DEFAULT_CACHE_DIR / "virtualenvs"),
),
"virtualenvs.prefer-active-python": (
boolean_validator,
boolean_normalizer,
False,
),
"experimental.new-installer": (
boolean_validator,
boolean_normalizer,
True,
),
"experimental.system-git-client": (
boolean_validator,
boolean_normalizer,
False,
),
"installer.parallel": (
boolean_validator,
boolean_normalizer,
True,
),
"installer.max-workers": (
lambda val: int(val) > 0,
int_normalizer,
None,
),
"virtualenvs.prompt": (
str,
lambda val: str(val),
"{project_name}-py{python_version}",
), ),
"virtualenvs.path": (str, lambda val: str(Path(val))),
"virtualenvs.prefer-active-python": (boolean_validator, boolean_normalizer),
"experimental.new-installer": (boolean_validator, boolean_normalizer),
"experimental.system-git-client": (boolean_validator, boolean_normalizer),
"installer.parallel": (boolean_validator, boolean_normalizer),
"installer.max-workers": (lambda val: int(val) > 0, int_normalizer),
"virtualenvs.prompt": (str, lambda val: str(val)),
"installer.no-binary": ( "installer.no-binary": (
PackageFilterPolicy.validator, PackageFilterPolicy.validator,
PackageFilterPolicy.normalize, PackageFilterPolicy.normalize,
None,
), ),
} }
...@@ -196,8 +152,7 @@ To remove a repository (repo is a short alias for repositories): ...@@ -196,8 +152,7 @@ To remove a repository (repo is a short alias for repositories):
values: list[str] = self.argument("value") values: list[str] = self.argument("value")
unique_config_values = self.unique_config_values if setting_key in self.unique_config_values:
if setting_key in unique_config_values:
if self.option("unset"): if self.option("unset"):
config.config_source.remove_property(setting_key) config.config_source.remove_property(setting_key)
return 0 return 0
...@@ -205,7 +160,7 @@ To remove a repository (repo is a short alias for repositories): ...@@ -205,7 +160,7 @@ To remove a repository (repo is a short alias for repositories):
return self._handle_single_value( return self._handle_single_value(
config.config_source, config.config_source,
setting_key, setting_key,
unique_config_values[setting_key], self.unique_config_values[setting_key],
values, values,
) )
...@@ -310,10 +265,10 @@ To remove a repository (repo is a short alias for repositories): ...@@ -310,10 +265,10 @@ To remove a repository (repo is a short alias for repositories):
self, self,
source: ConfigSource, source: ConfigSource,
key: str, key: str,
callbacks: tuple[Any, Any, Any], callbacks: tuple[Any, Any],
values: list[Any], values: list[Any],
) -> int: ) -> int:
validator, normalizer, _ = callbacks validator, normalizer = callbacks
if len(values) > 1: if len(values) > 1:
raise RuntimeError("You can only pass one value.") raise RuntimeError("You can only pass one value.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment