fix: address all warnings from pylint

This commit is contained in:
Lance Edgar 2025-09-01 19:56:16 -05:00
parent ff573cc17d
commit b9a34003c1
9 changed files with 43 additions and 18 deletions

4
.pylintrc Normal file
View file

@ -0,0 +1,4 @@
# -*- mode: conf; -*-
[MESSAGES CONTROL]
disable=fixme

View file

@ -8,6 +8,9 @@ This is `Sideshow`_ with integration for `CORE-POS`_.
.. _CORE-POS: https://www.core-pos.com/
.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen
:target: https://github.com/pylint-dev/pylint
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black

View file

@ -39,7 +39,7 @@ dependencies = [
[project.optional-dependencies]
docs = ["Sphinx", "furo"]
tests = ["pytest-cov", "tox"]
tests = ["pylint", "pytest", "pytest-cov", "tox"]
[project.entry-points."paste.app_factory"]

View file

@ -43,7 +43,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
for more info.
"""
def autocomplete_customers_external(self, session, term, user=None):
def autocomplete_customers_external( # pylint: disable=empty-docstring
self, session, term, user=None
):
""" """
corepos = self.app.get_corepos_handler()
op_model = corepos.get_model_office_op()
@ -84,7 +86,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
op_session.close()
return results
def refresh_batch_from_external_customer(self, batch):
def refresh_batch_from_external_customer( # pylint: disable=empty-docstring
self, batch
):
""" """
corepos = self.app.get_corepos_handler()
op_model = corepos.get_model_office_op()
@ -108,8 +112,8 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
.options(orm.joinedload(op_model.CustomerClassic.member_info))
.one()
)
except orm.exc.NoResultFound:
raise ValueError(f"CORE-POS Customer not found: {batch.customer_id}")
except orm.exc.NoResultFound as e:
raise ValueError(f"CORE-POS Customer not found: {batch.customer_id}") from e
batch.customer_name = str(customer)
batch.phone_number = customer.member_info.phone
@ -117,7 +121,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
op_session.close()
def autocomplete_products_external(self, session, term, user=None):
def autocomplete_products_external( # pylint: disable=empty-docstring
self, session, term, user=None
):
""" """
corepos = self.app.get_corepos_handler()
op_model = corepos.get_model_office_op()
@ -158,7 +164,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
op_session.close()
return results
def get_product_info_external(self, session, product_id, user=None):
def get_product_info_external( # pylint: disable=empty-docstring
self, session, product_id, user=None
):
""" """
corepos = self.app.get_corepos_handler()
op_model = corepos.get_model_office_op()
@ -170,8 +178,8 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
.filter(op_model.Product.upc == product_id)
.one()
)
except orm.exc.NoResultFound:
raise ValueError(f"CORE-POS Product not found: {product_id}")
except orm.exc.NoResultFound as e:
raise ValueError(f"CORE-POS Product not found: {product_id}") from e
data = {
"product_id": product.upc,
@ -196,7 +204,7 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
op_session.close()
return data
def refresh_row_from_external_product(self, row):
def refresh_row_from_external_product(self, row): # pylint: disable=empty-docstring
""" """
corepos = self.app.get_corepos_handler()
op_model = corepos.get_model_office_op()
@ -208,8 +216,8 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
.filter(op_model.Product.upc == row.product_id)
.one()
)
except orm.exc.NoResultFound:
raise ValueError(f"CORE-POS Product not found: {row.product_id}")
except orm.exc.NoResultFound as e:
raise ValueError(f"CORE-POS Product not found: {row.product_id}") from e
row.product_scancode = product.upc
row.product_brand = product.brand
@ -233,14 +241,20 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
op_session.close()
def get_case_size_for_external_product(self, product):
def get_case_size_for_external_product( # pylint: disable=empty-docstring
self, product
):
""" """
if product.vendor_items:
item = product.vendor_items[0]
if item.units is not None:
return decimal.Decimal(f"{item.units:0.4f}")
return None
def get_unit_price_reg_for_external_product(self, product):
def get_unit_price_reg_for_external_product( # pylint: disable=empty-docstring
self, product
):
""" """
if product.normal_price is not None:
return decimal.Decimal(f"{product.normal_price:0.3f}")
return None

View file

@ -36,7 +36,7 @@ class SideshowCoreposConfig(WuttaConfigExtension):
key = "sideshow_corepos"
def configure(self, config):
def configure(self, config): # pylint: disable=empty-docstring
""" """
# batch handlers

View file

@ -25,5 +25,5 @@ Sideshow-COREPOS - Case/Special Order Tracker for CORE-POS
"""
def includeme(config):
def includeme(config): # pylint: disable=missing-function-docstring
config.include("sideshow_corepos.web.views")

View file

@ -29,7 +29,7 @@ from wuttaweb import app as base
from wutta_corepos.web.db import CoreOpSession
def main(global_config, **settings):
def main(global_config, **settings): # pylint: disable=unused-argument
"""
Make and return the WSGI app (Paste entry point).
"""

View file

@ -27,7 +27,7 @@ This adds config for readonly views for CORE-POS members and products.
"""
def includeme(config):
def includeme(config): # pylint: disable=missing-function-docstring
# CORE-POS views
config.include("wutta_corepos.web.views.corepos.members")

View file

@ -6,6 +6,10 @@ envlist = py38, py39, py310, py311
extras = tests
commands = pytest {posargs}
[testenv:pylint]
basepython = python3.11
commands = pylint sideshow_corepos
[testenv:coverage]
basepython = python3.11
commands = pytest --cov=sideshow_corepos --cov-report=html --cov-fail-under=100