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

Breaks use of --config arguments in management commands #343

Open
PeterJCLaw opened this issue Sep 7, 2022 · 0 comments
Open

Breaks use of --config arguments in management commands #343

PeterJCLaw opened this issue Sep 7, 2022 · 0 comments

Comments

@PeterJCLaw
Copy link

If a project wants to use django-configurations then doing so precludes the use of --config (or any other shortening of --configuration) in all the management commands in the project, including those inherited from other packages.

This appears to be due to the default behaviour of argparse.ArgumentParser, specifically the allow_abbrev argument, in combination with they way that ConfigurationImporter checks for the configuration to use from the command line -- namely by running Django's argument parser before any other arguments have been added.

I'm hitting this with https://github.com/thread/django-lightweight-queue/, whose queue_runner command has a --config which is being hidden by this behaviour. The result of which is that queue_runner --config=./special-config.py results in an AttributeError: "Couldn't find configuration './special-config.py' in module '.settings'".

While in some cases it may be possible to change to just not using conflicting argument names, this won't always be possible if, for example, the name comes from a separate library.

I suspect it may be possible to fix this in django-configurations by changing ConfigurationImporter to set allow_abbrev=False in the parser it creates in check_options, though I realise this might be considered a breaking change.

PeterJCLaw added a commit to thread/django-lightweight-queue that referenced this issue Sep 7, 2022
This works around 'django-configurations' interception of arguments
which are contractions of its '--configuration' argument. We also
take the opportunity to slightly clarify the name of this arugment.

See jazzband/django-configurations#343
PeterJCLaw added a commit to thread/django-lightweight-queue that referenced this issue Sep 7, 2022
This works around 'django-configurations' interception of arguments
which are contractions of its '--configuration' argument. We also
take the opportunity to slightly clarify the name of this argument.

See jazzband/django-configurations#343
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

No branches or pull requests

1 participant