add initial pylint config, just one checker
will clean these up one by one so we can use fail-under=10 for buildbot pylint
This commit is contained in:
parent
ef93a563e7
commit
ac65ec891b
4 changed files with 30 additions and 13 deletions
5
.pylintrc
Normal file
5
.pylintrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
# -*- mode: conf; -*-
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=all
|
||||
enable=dangerous-default-value
|
|
@ -61,10 +61,12 @@ class WuttaConfig:
|
|||
* one or more INI files
|
||||
* "defaults" provided by app logic
|
||||
|
||||
:param files: List of file paths from which to read config values.
|
||||
:param files: Optional list of file paths from which to read
|
||||
config values.
|
||||
|
||||
:param defaults: Initial values to use as defaults. This gets
|
||||
converted to :attr:`defaults` during construction.
|
||||
:param defaults: Optional dict of initial values to use as
|
||||
defaults. This gets converted to :attr:`defaults` during
|
||||
construction.
|
||||
|
||||
:param appname: Value to assign for :attr:`appname`.
|
||||
|
||||
|
@ -187,8 +189,8 @@ class WuttaConfig:
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
files=[],
|
||||
defaults={},
|
||||
files=None,
|
||||
defaults=None,
|
||||
appname='wutta',
|
||||
usedb=None,
|
||||
preferdb=None,
|
||||
|
@ -199,11 +201,11 @@ class WuttaConfig:
|
|||
|
||||
# read all files requested
|
||||
self.files_read = []
|
||||
for path in files:
|
||||
for path in files or []:
|
||||
self._load_ini_configs(path, configs, require=True)
|
||||
|
||||
# add config for use w/ setdefault()
|
||||
self.defaults = configuration.Configuration(defaults)
|
||||
self.defaults = configuration.Configuration(defaults or {})
|
||||
configs.append(self.defaults)
|
||||
|
||||
# master config set
|
||||
|
|
|
@ -370,7 +370,7 @@ class EmailHandler(GenericHandler):
|
|||
"""
|
||||
return Message(**kwargs)
|
||||
|
||||
def make_auto_message(self, key, context={}, default_subject=None, **kwargs):
|
||||
def make_auto_message(self, key, context=None, default_subject=None, **kwargs):
|
||||
"""
|
||||
Make a new email message using config to determine its
|
||||
properties, and auto-generating body from a template.
|
||||
|
@ -407,6 +407,7 @@ class EmailHandler(GenericHandler):
|
|||
* :meth:`get_auto_txt_body()`
|
||||
* :meth:`get_auto_html_body()`
|
||||
"""
|
||||
context = context or {}
|
||||
kwargs['key'] = key
|
||||
if 'sender' not in kwargs:
|
||||
kwargs['sender'] = self.get_auto_sender(key)
|
||||
|
@ -452,7 +453,7 @@ class EmailHandler(GenericHandler):
|
|||
# fall back to global default, if present
|
||||
return self.config.get(f'{self.config.appname}.email.default.replyto')
|
||||
|
||||
def get_auto_subject(self, key, context={}, rendered=True, setting=None, default=None):
|
||||
def get_auto_subject(self, key, context=None, rendered=True, setting=None, default=None):
|
||||
"""
|
||||
Returns automatic :attr:`~wuttjamaican.email.Message.subject`
|
||||
line for a message, as determined by config.
|
||||
|
@ -481,6 +482,7 @@ class EmailHandler(GenericHandler):
|
|||
if not rendered:
|
||||
return template
|
||||
|
||||
context = context or {}
|
||||
return Template(template).render(**context)
|
||||
|
||||
def get_auto_subject_template(self, key, setting=None, default=None):
|
||||
|
@ -561,7 +563,7 @@ class EmailHandler(GenericHandler):
|
|||
return self.config.get_list(f'{self.config.appname}.email.default.{typ}',
|
||||
default=[])
|
||||
|
||||
def get_auto_txt_body(self, key, context={}):
|
||||
def get_auto_txt_body(self, key, context=None):
|
||||
"""
|
||||
Returns automatic :attr:`~wuttjamaican.email.Message.txt_body`
|
||||
content for a message, as determined by config. This renders
|
||||
|
@ -569,9 +571,10 @@ class EmailHandler(GenericHandler):
|
|||
"""
|
||||
template = self.get_auto_body_template(key, 'txt')
|
||||
if template:
|
||||
context = context or {}
|
||||
return template.render(**context)
|
||||
|
||||
def get_auto_html_body(self, key, context={}):
|
||||
def get_auto_html_body(self, key, context=None):
|
||||
"""
|
||||
Returns automatic
|
||||
:attr:`~wuttjamaican.email.Message.html_body` content for a
|
||||
|
@ -580,6 +583,7 @@ class EmailHandler(GenericHandler):
|
|||
"""
|
||||
template = self.get_auto_body_template(key, 'html')
|
||||
if template:
|
||||
context = context or {}
|
||||
return template.render(**context)
|
||||
|
||||
def get_auto_body_template(self, key, mode):
|
||||
|
@ -740,7 +744,7 @@ class EmailHandler(GenericHandler):
|
|||
return self.config.get_bool(f'{self.config.appname}.mail.send_emails',
|
||||
default=False)
|
||||
|
||||
def send_email(self, key=None, context={}, message=None, sender=None, recips=None, **kwargs):
|
||||
def send_email(self, key=None, context=None, message=None, sender=None, recips=None, **kwargs):
|
||||
"""
|
||||
Send an email message.
|
||||
|
||||
|
@ -810,7 +814,7 @@ class EmailHandler(GenericHandler):
|
|||
# auto-create message from key + context
|
||||
if sender:
|
||||
kwargs['sender'] = sender
|
||||
message = self.make_auto_message(key, context, **kwargs)
|
||||
message = self.make_auto_message(key, context or {}, **kwargs)
|
||||
if not (message.txt_body or message.html_body):
|
||||
raise RuntimeError(f"message (type: {key}) has no body - "
|
||||
"perhaps template file not found?")
|
||||
|
|
6
tox.ini
6
tox.ini
|
@ -10,6 +10,12 @@ commands = pytest {posargs}
|
|||
[testenv:nox]
|
||||
extras = tests
|
||||
|
||||
[testenv:pylint]
|
||||
basepython = python3.11
|
||||
extras =
|
||||
deps = pylint
|
||||
commands = pylint wuttjamaican
|
||||
|
||||
[testenv:coverage]
|
||||
basepython = python3.11
|
||||
extras = db,tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue