fix: address all warnings from pylint
This commit is contained in:
parent
ff573cc17d
commit
b9a34003c1
9 changed files with 43 additions and 18 deletions
4
.pylintrc
Normal file
4
.pylintrc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# -*- mode: conf; -*-
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
disable=fixme
|
|
@ -8,6 +8,9 @@ This is `Sideshow`_ with integration for `CORE-POS`_.
|
||||||
|
|
||||||
.. _CORE-POS: https://www.core-pos.com/
|
.. _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
|
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
||||||
:target: https://github.com/psf/black
|
:target: https://github.com/psf/black
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ dependencies = [
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
docs = ["Sphinx", "furo"]
|
docs = ["Sphinx", "furo"]
|
||||||
tests = ["pytest-cov", "tox"]
|
tests = ["pylint", "pytest", "pytest-cov", "tox"]
|
||||||
|
|
||||||
|
|
||||||
[project.entry-points."paste.app_factory"]
|
[project.entry-points."paste.app_factory"]
|
||||||
|
|
|
@ -43,7 +43,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
for more info.
|
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()
|
corepos = self.app.get_corepos_handler()
|
||||||
op_model = corepos.get_model_office_op()
|
op_model = corepos.get_model_office_op()
|
||||||
|
@ -84,7 +86,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
op_session.close()
|
op_session.close()
|
||||||
return results
|
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()
|
corepos = self.app.get_corepos_handler()
|
||||||
op_model = corepos.get_model_office_op()
|
op_model = corepos.get_model_office_op()
|
||||||
|
@ -108,8 +112,8 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
.options(orm.joinedload(op_model.CustomerClassic.member_info))
|
.options(orm.joinedload(op_model.CustomerClassic.member_info))
|
||||||
.one()
|
.one()
|
||||||
)
|
)
|
||||||
except orm.exc.NoResultFound:
|
except orm.exc.NoResultFound as e:
|
||||||
raise ValueError(f"CORE-POS Customer not found: {batch.customer_id}")
|
raise ValueError(f"CORE-POS Customer not found: {batch.customer_id}") from e
|
||||||
|
|
||||||
batch.customer_name = str(customer)
|
batch.customer_name = str(customer)
|
||||||
batch.phone_number = customer.member_info.phone
|
batch.phone_number = customer.member_info.phone
|
||||||
|
@ -117,7 +121,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
|
|
||||||
op_session.close()
|
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()
|
corepos = self.app.get_corepos_handler()
|
||||||
op_model = corepos.get_model_office_op()
|
op_model = corepos.get_model_office_op()
|
||||||
|
@ -158,7 +164,9 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
op_session.close()
|
op_session.close()
|
||||||
return results
|
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()
|
corepos = self.app.get_corepos_handler()
|
||||||
op_model = corepos.get_model_office_op()
|
op_model = corepos.get_model_office_op()
|
||||||
|
@ -170,8 +178,8 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
.filter(op_model.Product.upc == product_id)
|
.filter(op_model.Product.upc == product_id)
|
||||||
.one()
|
.one()
|
||||||
)
|
)
|
||||||
except orm.exc.NoResultFound:
|
except orm.exc.NoResultFound as e:
|
||||||
raise ValueError(f"CORE-POS Product not found: {product_id}")
|
raise ValueError(f"CORE-POS Product not found: {product_id}") from e
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"product_id": product.upc,
|
"product_id": product.upc,
|
||||||
|
@ -196,7 +204,7 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
op_session.close()
|
op_session.close()
|
||||||
return data
|
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()
|
corepos = self.app.get_corepos_handler()
|
||||||
op_model = corepos.get_model_office_op()
|
op_model = corepos.get_model_office_op()
|
||||||
|
@ -208,8 +216,8 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
.filter(op_model.Product.upc == row.product_id)
|
.filter(op_model.Product.upc == row.product_id)
|
||||||
.one()
|
.one()
|
||||||
)
|
)
|
||||||
except orm.exc.NoResultFound:
|
except orm.exc.NoResultFound as e:
|
||||||
raise ValueError(f"CORE-POS Product not found: {row.product_id}")
|
raise ValueError(f"CORE-POS Product not found: {row.product_id}") from e
|
||||||
|
|
||||||
row.product_scancode = product.upc
|
row.product_scancode = product.upc
|
||||||
row.product_brand = product.brand
|
row.product_brand = product.brand
|
||||||
|
@ -233,14 +241,20 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||||
|
|
||||||
op_session.close()
|
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:
|
if product.vendor_items:
|
||||||
item = product.vendor_items[0]
|
item = product.vendor_items[0]
|
||||||
if item.units is not None:
|
if item.units is not None:
|
||||||
return decimal.Decimal(f"{item.units:0.4f}")
|
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:
|
if product.normal_price is not None:
|
||||||
return decimal.Decimal(f"{product.normal_price:0.3f}")
|
return decimal.Decimal(f"{product.normal_price:0.3f}")
|
||||||
|
return None
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SideshowCoreposConfig(WuttaConfigExtension):
|
||||||
|
|
||||||
key = "sideshow_corepos"
|
key = "sideshow_corepos"
|
||||||
|
|
||||||
def configure(self, config):
|
def configure(self, config): # pylint: disable=empty-docstring
|
||||||
""" """
|
""" """
|
||||||
|
|
||||||
# batch handlers
|
# batch handlers
|
||||||
|
|
|
@ -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")
|
config.include("sideshow_corepos.web.views")
|
||||||
|
|
|
@ -29,7 +29,7 @@ from wuttaweb import app as base
|
||||||
from wutta_corepos.web.db import CoreOpSession
|
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).
|
Make and return the WSGI app (Paste entry point).
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -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
|
# CORE-POS views
|
||||||
config.include("wutta_corepos.web.views.corepos.members")
|
config.include("wutta_corepos.web.views.corepos.members")
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -6,6 +6,10 @@ envlist = py38, py39, py310, py311
|
||||||
extras = tests
|
extras = tests
|
||||||
commands = pytest {posargs}
|
commands = pytest {posargs}
|
||||||
|
|
||||||
|
[testenv:pylint]
|
||||||
|
basepython = python3.11
|
||||||
|
commands = pylint sideshow_corepos
|
||||||
|
|
||||||
[testenv:coverage]
|
[testenv:coverage]
|
||||||
basepython = python3.11
|
basepython = python3.11
|
||||||
commands = pytest --cov=sideshow_corepos --cov-report=html --cov-fail-under=100
|
commands = pytest --cov=sideshow_corepos --cov-report=html --cov-fail-under=100
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue