Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI handling of configuration file arguments #131

Merged
merged 6 commits into from
Dec 13, 2023

Conversation

t00sa
Copy link
Contributor

@t00sa t00sa commented Aug 25, 2023

A combination of issues #129 and #130, this makes the -configuration command line argument compulsory, checks that that file passed as an argument exists, and confirms that the suffix matches a valid python file. This allows the CLI's ArgumentParser to return an error to the user fairly early on, rather than allowing a StylistException to propagate to the top level as happened previously.

t00sa added 3 commits August 25, 2023 13:16
This updates the stylist CLI to make the -configuration compulsory.
This will cause the command to fail early if the configuration is
incorrect, allowing ArgumentParser to display a meaningful error
message.
This updates the CLI to check whether the configuration file exists and
whether it has a valid python extension.  This allows ArgumentParser to
display a meaningful error if the configuration is not valid.
As per the guidance, I have added my name to the list of contributors.
@t00sa t00sa requested a review from MatthewHambley August 25, 2023 13:37
@t00sa t00sa linked an issue Aug 25, 2023 that may be closed by this pull request
@MatthewHambley
Copy link
Collaborator

I have created issue #132 to capture potential future requirements.

Copy link
Collaborator

@MatthewHambley MatthewHambley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of making optional (starting with a hyphen) arguments compulsory but given that #132 exists and we therefore might make it optional again I think it is acceptable.

I have one request which is that you look into using PyTest's magic fixtures as they may tidy up the test code a little.

unit-tests/__main__test.py Outdated Show resolved Hide resolved
Create an overload method which shallow merges the pipes and styles
attributes of a second Configuration into the current instance.  This
is intended to be used to allow per-site, per-user, and per-project
configurations to be combined into a single entity.
Reviewer has suggested changing the argument handling to prevent the
user from having to specify an option because this is contrary to
spirit of making the flag voluntary.  Instead, the code checks a
variety of locations before raising an exception if the configuration
cannot be found.

This also improves temporary directory handling in tests as
recommended by the reviewer, replacing clunky custom code with
a function provide pytest.
The __configure() function return value in the main script had the
wrong type hinting.  This changes the hinting to match None in the
event of a configuration problem.
@t00sa t00sa requested a review from MatthewHambley December 12, 2023 20:26
Copy link
Collaborator

@MatthewHambley MatthewHambley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change is ready for trunk.

@MatthewHambley MatthewHambley merged commit fffc2a8 into master Dec 13, 2023
6 checks passed
@MatthewHambley MatthewHambley deleted the 129-is-configuration-argument-always-needed branch December 13, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is configuration argument always needed?
2 participants