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

Is configuration argument always needed? #129

Closed
t00sa opened this issue Aug 22, 2023 · 2 comments · Fixed by #131
Closed

Is configuration argument always needed? #129

t00sa opened this issue Aug 22, 2023 · 2 comments · Fixed by #131

Comments

@t00sa
Copy link
Contributor

t00sa commented Aug 22, 2023

While testing the CLI for PR 123, I found that if the -configuration command line argument was omitted, I got an error from a later point in the code:

linux> python -m stylist -style line_length_default check_nan_inf_mod.f90
Traceback (most recent call last):
  File "/net/project/ukmo/scitools/opt_scitools/conda/deployments/default-2023_05_04/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/net/project/ukmo/scitools/opt_scitools/conda/deployments/default-2023_05_04/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/var/tmp/persistent/stylist/source/stylist/__main__.py", line 203, in <module>
    main()
  File "/var/tmp/persistent/stylist/source/stylist/__main__.py", line 189, in main
    configuration = __configure(arguments.configuration)
  File "/var/tmp/persistent/stylist/source/stylist/__main__.py", line 111, in __configure
    configuration = load_configuration(project_file)
  File "/var/tmp/persistent/stylist/source/stylist/configuration.py", line 53, in load_configuration
    raise StylistException(message)
stylist.StylistException: Unable to find configuration file: None
linux> 

If -configuration is always necessary - as seems to be the case - it would be cleaner to define it with required=True to force an error during command line argument processing.

@MatthewHambley
Copy link
Collaborator

Alternatively there may be a sensible default configuration. In which case specifying one is still optional.

@MatthewHambley
Copy link
Collaborator

Having looked further into this, the plan was to support a hierarchy of configuration. A site configuration in /etc/, then a personal configuration in $HOME/ then a project configuration. An error would only be raised if, after loading them all in order, there was still no usable configuration.

However it is not clear to me if anyone will ever want site or personal configurations. I suspect only project configurations are useful.

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 a pull request may close this issue.

2 participants