3
0
Fork 0

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:
Lance Edgar 2025-08-30 15:46:42 -05:00
parent ef93a563e7
commit ac65ec891b
4 changed files with 30 additions and 13 deletions

5
.pylintrc Normal file
View file

@ -0,0 +1,5 @@
# -*- mode: conf; -*-
[MESSAGES CONTROL]
disable=all
enable=dangerous-default-value

View file

@ -61,10 +61,12 @@ class WuttaConfig:
* one or more INI files * one or more INI files
* "defaults" provided by app logic * "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 :param defaults: Optional dict of initial values to use as
converted to :attr:`defaults` during construction. defaults. This gets converted to :attr:`defaults` during
construction.
:param appname: Value to assign for :attr:`appname`. :param appname: Value to assign for :attr:`appname`.
@ -187,8 +189,8 @@ class WuttaConfig:
def __init__( def __init__(
self, self,
files=[], files=None,
defaults={}, defaults=None,
appname='wutta', appname='wutta',
usedb=None, usedb=None,
preferdb=None, preferdb=None,
@ -199,11 +201,11 @@ class WuttaConfig:
# read all files requested # read all files requested
self.files_read = [] self.files_read = []
for path in files: for path in files or []:
self._load_ini_configs(path, configs, require=True) self._load_ini_configs(path, configs, require=True)
# add config for use w/ setdefault() # add config for use w/ setdefault()
self.defaults = configuration.Configuration(defaults) self.defaults = configuration.Configuration(defaults or {})
configs.append(self.defaults) configs.append(self.defaults)
# master config set # master config set

View file

@ -370,7 +370,7 @@ class EmailHandler(GenericHandler):
""" """
return Message(**kwargs) 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 Make a new email message using config to determine its
properties, and auto-generating body from a template. properties, and auto-generating body from a template.
@ -407,6 +407,7 @@ class EmailHandler(GenericHandler):
* :meth:`get_auto_txt_body()` * :meth:`get_auto_txt_body()`
* :meth:`get_auto_html_body()` * :meth:`get_auto_html_body()`
""" """
context = context or {}
kwargs['key'] = key kwargs['key'] = key
if 'sender' not in kwargs: if 'sender' not in kwargs:
kwargs['sender'] = self.get_auto_sender(key) kwargs['sender'] = self.get_auto_sender(key)
@ -452,7 +453,7 @@ class EmailHandler(GenericHandler):
# fall back to global default, if present # fall back to global default, if present
return self.config.get(f'{self.config.appname}.email.default.replyto') 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` Returns automatic :attr:`~wuttjamaican.email.Message.subject`
line for a message, as determined by config. line for a message, as determined by config.
@ -481,6 +482,7 @@ class EmailHandler(GenericHandler):
if not rendered: if not rendered:
return template return template
context = context or {}
return Template(template).render(**context) return Template(template).render(**context)
def get_auto_subject_template(self, key, setting=None, default=None): 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}', return self.config.get_list(f'{self.config.appname}.email.default.{typ}',
default=[]) 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` Returns automatic :attr:`~wuttjamaican.email.Message.txt_body`
content for a message, as determined by config. This renders 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') template = self.get_auto_body_template(key, 'txt')
if template: if template:
context = context or {}
return template.render(**context) return template.render(**context)
def get_auto_html_body(self, key, context={}): def get_auto_html_body(self, key, context=None):
""" """
Returns automatic Returns automatic
:attr:`~wuttjamaican.email.Message.html_body` content for a :attr:`~wuttjamaican.email.Message.html_body` content for a
@ -580,6 +583,7 @@ class EmailHandler(GenericHandler):
""" """
template = self.get_auto_body_template(key, 'html') template = self.get_auto_body_template(key, 'html')
if template: if template:
context = context or {}
return template.render(**context) return template.render(**context)
def get_auto_body_template(self, key, mode): 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', return self.config.get_bool(f'{self.config.appname}.mail.send_emails',
default=False) 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. Send an email message.
@ -810,7 +814,7 @@ class EmailHandler(GenericHandler):
# auto-create message from key + context # auto-create message from key + context
if sender: if sender:
kwargs['sender'] = 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): if not (message.txt_body or message.html_body):
raise RuntimeError(f"message (type: {key}) has no body - " raise RuntimeError(f"message (type: {key}) has no body - "
"perhaps template file not found?") "perhaps template file not found?")

View file

@ -10,6 +10,12 @@ commands = pytest {posargs}
[testenv:nox] [testenv:nox]
extras = tests extras = tests
[testenv:pylint]
basepython = python3.11
extras =
deps = pylint
commands = pylint wuttjamaican
[testenv:coverage] [testenv:coverage]
basepython = python3.11 basepython = python3.11
extras = db,tests extras = db,tests