You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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 theallow_abbrev
argument, in combination with they way thatConfigurationImporter
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 thatqueue_runner --config=./special-config.py
results in anAttributeError
: "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 changingConfigurationImporter
to setallow_abbrev=False
in the parser it creates incheck_options
, though I realise this might be considered a breaking change.The text was updated successfully, but these errors were encountered: