From e8e364ddc6a19cb773f0d871dfba9047400d6a5f Mon Sep 17 00:00:00 2001 From: Adam McKellar Date: Tue, 21 May 2024 16:23:51 +0200 Subject: [PATCH] Fixed wrong package name in readme. Changed option being required if there is a default (cosmetical)? Changed part of unit test for said fix. --- README.md | 9 +++++---- .../get_flags_and_options_from_schema.py | 2 +- tests/data/flags_options_example.schema.yml | 2 +- tests/test_get_flags_and_options_from_schema.py | 6 ++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e7b5880..fb055ea 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [![Documentation Status](https://readthedocs.org/projects/installation-instruction/badge/?version=latest)](https://installation-instruction.readthedocs.io/en/latest/?badge=latest) [![codecov](https://codecov.io/gh/instructions-d-installation/installation-instruction/graph/badge.svg?token=5AIH36HYG3)](https://codecov.io/gh/instructions-d-installation/installation-instruction) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Finstructions-d-installation%2Finstallation-instruction.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Finstructions-d-installation%2Finstallation-instruction?ref=badge_small) +![PyPI - Version](https://img.shields.io/pypi/v/installation-instruction) @@ -16,14 +17,14 @@ ### [pipx](https://github.com/pypa/pipx) ``` -pipx install installation_instruction +pipx install installation-instruction ``` ### pip ``` -python -m pip install installation_instruction +python -m pip install installation-instruction ``` @@ -31,7 +32,7 @@ python -m pip install installation_instruction *(Don't try at home.)* ```yaml -name: installation_instruction +name: installation-instruction type: object properties: method: @@ -44,7 +45,7 @@ properties: {% else %} pipx {% endif %} - install installation_instruction + install installation-instruction ``` diff --git a/installation_instruction/get_flags_and_options_from_schema.py b/installation_instruction/get_flags_and_options_from_schema.py index c976481..fdf0820 100644 --- a/installation_instruction/get_flags_and_options_from_schema.py +++ b/installation_instruction/get_flags_and_options_from_schema.py @@ -48,7 +48,7 @@ def get_flags_and_options(schema: dict) -> list[Option]: else: option_type = SCHEMA_TO_CLICK_TYPE_MAPPING.get(option_type, click.STRING) - required = key in required_args + required = (key in required_args) and not option_default options.append(Option( param_decls=[option_name], diff --git a/tests/data/flags_options_example.schema.yml b/tests/data/flags_options_example.schema.yml index e70e986..43f01db 100644 --- a/tests/data/flags_options_example.schema.yml +++ b/tests/data/flags_options_example.schema.yml @@ -11,7 +11,7 @@ properties: - Windows - macOS - Linux - default: Windows + packager: title: Packager diff --git a/tests/test_get_flags_and_options_from_schema.py b/tests/test_get_flags_and_options_from_schema.py index 19fd0d8..1d4629b 100644 --- a/tests/test_get_flags_and_options_from_schema.py +++ b/tests/test_get_flags_and_options_from_schema.py @@ -14,8 +14,6 @@ from installation_instruction.get_flags_and_options_from_schema import get_flags_and_options -import click -import yaml def test_get_flags_and_options(test_data_flags_options): example_schema = test_data_flags_options @@ -26,11 +24,11 @@ def test_get_flags_and_options(test_data_flags_options): assert options[0].opts == ["--os"] assert options[0].help == "The operating system in which the package is installed." assert options[0].required == True - assert options[0].default == "Windows" + assert options[0].default == None assert options[1].opts == ["--packager"] assert options[1].help == "The package manager of your choosing." - assert options[1].required == True + assert options[1].required == False assert options[1].default == "pip" assert options[2].opts == ["--virtualenv"]