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
does not seem to require the parser argument. This method is called from the class gunicorn.app.base.Application by the load_config method, reproduced below:
defload_config(self):
# parse console argsparser=self.cfg.parser()
args=parser.parse_args()
# optional settings from appscfg=self.init(args, parser, args.args) # removed parser# set up import paths and follow symlinksself.chdir()
# Load up the any app specific configurationifcfg:
fork, vincfg.items():
self.cfg.set(k.lower(), v)
env_args=parser.parse_args(self.cfg.get_cmd_args_from_env())
ifargs.config:
self.load_config_from_file(args.config)
elifenv_args.config:
self.load_config_from_file(env_args.config)
else:
default_config=get_default_config_file()
ifdefault_configisnotNone:
self.load_config_from_file(default_config)
# Load up environment configurationfork, vinvars(env_args).items():
ifvisNone:
continueifk=="args":
continueself.cfg.set(k.lower(), v)
# Lastly, update the configuration with any command line settings.fork, vinvars(args).items():
ifvisNone:
continueifk=="args":
continueself.cfg.set(k.lower(), v)
# current directory might be changed by the config now# set up import paths and follow symlinksself.chdir()
specifically, it is called at this line: cfg = self.init(args, parser, args.args).
I've run Gunicorn tests and specifically the file tests.test_config.py and all the tests before and after the
removal of the argument parser are the same. Therefore, is there any particular reason for this argument to be included?
3. Tests:
platform linux -- Python 3.10.12, pytest-8.0.0, pluggy-1.4.0
configfile: pyproject.toml
plugins: cov-4.1.0
collected 251 items
....
---------- coverage: platform linux, python 3.10.12-final-0 ----------
Coverage XML written to file coverage.xml
$\large\color{green}{\textsf{=================== 251 passed in 6.98s =============================}}$
True, but gunicorn in general lacks a distinction between public API (that downstream users can trust to not go away without notice) and internal (preferably underscore-prefixed) API. This one is rather clearly the former case though, being in the parent class and thus reasonably copied to any custom overrides.
I'd suggest approaching cleaning up such oddities from two separate vectors:
add annotation stubs (.pyi) and inline them (after dropping 3.7 compat) and later, so people have an easier time adapting their code using static type checkers
internally, prefer keyword arguments wherever copying the full method signature is not desirable - while retaining compatibility with custom code still using positionals, emitting DeprecationWarning
welll the reason si that some class around (not released) is using this parser argument.
As for the method signature, I prefer explicit signatures myself. It doesn't matter this signature can change over the time, since it is expected that people use gunicorn as a service rather than a lib.
1. Argument removal description:
The method
self.init
defined in the classgunicorn.app.wsgiapp.WSGIApplicaton
and reproduced below:does not seem to require the
parser
argument. This method is called from the classgunicorn.app.base.Application
by theload_config
method, reproduced below:specifically, it is called at this line:
cfg = self.init(args, parser, args.args)
.I've run Gunicorn tests and specifically the file
tests.test_config.py
and all the tests before and after theremoval of the argument
parser
are the same. Therefore, is there any particular reason for this argument to be included?3. Tests:
4. Environment:
python --version$\large\color{red}{\textsf{|}}$ Python 3.10.12
OS specifics:
Virtual environment
End
The text was updated successfully, but these errors were encountered: